class documentation

Reads HTTP message from socket.

Method __init__ Reads an HTTP message from a socket.
Method ParseStartLine Parses the start line of a message.
Constant HEADER_LENGTH_MAX Undocumented
Constant PS_BODY Undocumented
Constant PS_COMPLETE Undocumented
Constant PS_HEADERS Undocumented
Constant PS_START_LINE Undocumented
Constant START_LINE_LENGTH_MAX Undocumented
Instance Variable body_buffer Undocumented
Instance Variable content_length Undocumented
Instance Variable header_buffer Undocumented
Instance Variable msg Undocumented
Instance Variable parser_status Undocumented
Instance Variable peer_will_close Undocumented
Instance Variable sock Undocumented
Instance Variable start_line_buffer Undocumented
Method _CheckHeaderLength Limits the header buffer size.
Method _CheckStartLineLength Limits the start line buffer size.
Method _ContinueParsing Main function for HTTP message state machine.
Method _ParseHeaders Parses the headers.
Method _WillPeerCloseConnection Evaluate whether peer will close the connection.
def __init__(self, sock, msg, read_timeout):

Reads an HTTP message from a socket.

Parameters
sock:socketSocket to be read from
msg:http.HttpMessageObject for the read message
read_timeout:floatRead timeout for socket
def ParseStartLine(self, start_line):

Parses the start line of a message.

Must be overridden by subclass.

Parameters
start_line:stringStart line string
PS_BODY: str =

Undocumented

Value
'entity-body'
PS_COMPLETE: str =

Undocumented

Value
'complete'
PS_HEADERS: str =

Undocumented

Value
'headers'
PS_START_LINE: str =

Undocumented

Value
'start-line'
body_buffer =

Undocumented

content_length =

Undocumented

header_buffer =

Undocumented

msg =

Undocumented

parser_status =

Undocumented

peer_will_close: bool =

Undocumented

sock =

Undocumented

start_line_buffer =

Undocumented

def _CheckHeaderLength(self, length):

Limits the header buffer size.

Parameters
length:intBuffer size
def _CheckStartLineLength(self, length):

Limits the start line buffer size.

Parameters
length:intBuffer size
def _ContinueParsing(self, buf, eof):

Main function for HTTP message state machine.

Parameters
buf:stringReceive buffer
eof:boolWhether we've reached EOF on the socket
Returns
stringUpdated receive buffer
def _ParseHeaders(self):

Parses the headers.

This function also adjusts internal variables based on header values.

RFC2616, section 4.3: The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers.

def _WillPeerCloseConnection(self):

Evaluate whether peer will close the connection.

Returns
boolWhether peer will close the connection