GNUnet 0.22.0
httpdomain.httpdomain.HTTPLexer Class Reference
Inheritance diagram for httpdomain.httpdomain.HTTPLexer:
[legend]
Collaboration diagram for httpdomain.httpdomain.HTTPLexer:
[legend]

Public Member Functions

def header_callback (self, match)
 
def continuous_header_callback (self, match)
 
def content_callback (self, match)
 
def header_callback (self, match)
 
def continuous_header_callback (self, match)
 
def content_callback (self, match)
 

Data Fields

 content_type
 

Static Public Attributes

string name = 'HTTP'
 
list aliases = ['http']
 
 flags = re.DOTALL
 
dictionary tokens
 

Detailed Description

Lexer for HTTP sessions.

Definition at line 697 of file httpdomain.py.

Member Function Documentation

◆ header_callback() [1/2]

def httpdomain.httpdomain.HTTPLexer.header_callback (   self,
  match 
)

Definition at line 705 of file httpdomain.py.

705 def header_callback(self, match):
706 if match.group(1).lower() == 'content-type':
707 content_type = match.group(5).strip()
708 if ';' in content_type:
709 content_type = content_type[:content_type.find(';')].strip()
710 self.content_type = content_type
711 yield match.start(1), Name.Attribute, match.group(1)
712 yield match.start(2), Text, match.group(2)
713 yield match.start(3), Operator, match.group(3)
714 yield match.start(4), Text, match.group(4)
715 yield match.start(5), Literal, match.group(5)
716 yield match.start(6), Text, match.group(6)
717

◆ continuous_header_callback() [1/2]

def httpdomain.httpdomain.HTTPLexer.continuous_header_callback (   self,
  match 
)

Definition at line 718 of file httpdomain.py.

718 def continuous_header_callback(self, match):
719 yield match.start(1), Text, match.group(1)
720 yield match.start(2), Literal, match.group(2)
721 yield match.start(3), Text, match.group(3)
722

◆ content_callback() [1/2]

def httpdomain.httpdomain.HTTPLexer.content_callback (   self,
  match 
)

Definition at line 723 of file httpdomain.py.

723 def content_callback(self, match):
724 content_type = getattr(self, 'content_type', None)
725 content = match.group()
726 offset = match.start()
727 if content_type:
728 from pygments.lexers import get_lexer_for_mimetype
729 try:
730 lexer = get_lexer_for_mimetype(content_type)
731 except ClassNotFound:
732 pass
733 else:
734 for idx, token, value in lexer.get_tokens_unprocessed(content):
735 yield offset + idx, token, value
736 return
737 yield offset, Text, content
738

◆ header_callback() [2/2]

def httpdomain.httpdomain.HTTPLexer.header_callback (   self,
  match 
)

Definition at line 705 of file httpdomain.py.

705 def header_callback(self, match):
706 if match.group(1).lower() == 'content-type':
707 content_type = match.group(5).strip()
708 if ';' in content_type:
709 content_type = content_type[:content_type.find(';')].strip()
710 self.content_type = content_type
711 yield match.start(1), Name.Attribute, match.group(1)
712 yield match.start(2), Text, match.group(2)
713 yield match.start(3), Operator, match.group(3)
714 yield match.start(4), Text, match.group(4)
715 yield match.start(5), Literal, match.group(5)
716 yield match.start(6), Text, match.group(6)
717

References httpdomain.httpdomain.HTTPLexer.content_type.

◆ continuous_header_callback() [2/2]

def httpdomain.httpdomain.HTTPLexer.continuous_header_callback (   self,
  match 
)

Definition at line 718 of file httpdomain.py.

718 def continuous_header_callback(self, match):
719 yield match.start(1), Text, match.group(1)
720 yield match.start(2), Literal, match.group(2)
721 yield match.start(3), Text, match.group(3)
722

◆ content_callback() [2/2]

def httpdomain.httpdomain.HTTPLexer.content_callback (   self,
  match 
)

Definition at line 723 of file httpdomain.py.

723 def content_callback(self, match):
724 content_type = getattr(self, 'content_type', None)
725 content = match.group()
726 offset = match.start()
727 if content_type:
728 from pygments.lexers import get_lexer_for_mimetype
729 try:
730 lexer = get_lexer_for_mimetype(content_type)
731 except ClassNotFound:
732 pass
733 else:
734 for idx, token, value in lexer.get_tokens_unprocessed(content):
735 yield offset + idx, token, value
736 return
737 yield offset, Text, content
738

Field Documentation

◆ name

string httpdomain.httpdomain.HTTPLexer.name = 'HTTP'
static

Definition at line 700 of file httpdomain.py.

◆ aliases

list httpdomain.httpdomain.HTTPLexer.aliases = ['http']
static

Definition at line 701 of file httpdomain.py.

◆ flags

httpdomain.httpdomain.HTTPLexer.flags = re.DOTALL
static

Definition at line 703 of file httpdomain.py.

◆ tokens

dictionary httpdomain.httpdomain.HTTPLexer.tokens
static
Initial value:
= {
'root': [
(r'(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|COPY)( +)([^ ]+)( +)'
r'(HTTPS?)(/)(1\.[01])(\r?\n|$)',
bygroups(Name.Function, Text, Name.Namespace, Text,
Keyword.Reserved, Operator, Number, Text),
'headers'),
(r'(HTTPS?)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
bygroups(Keyword.Reserved, Operator, Number, Text, Number,
Text, Name.Exception, Text),
'headers'),
],
'headers': [
(r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
(r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback),
(r'\r?\n', Text, 'content')
],
'content': [
(r'.+', content_callback)
]
}

Definition at line 739 of file httpdomain.py.

◆ content_type

httpdomain.httpdomain.HTTPLexer.content_type

Definition at line 710 of file httpdomain.py.

Referenced by httpdomain.httpdomain.HTTPLexer.header_callback().


The documentation for this class was generated from the following files: