Package ganeti :: Package http :: Class HttpMessageReader
[hide private]
[frames] | no frames]

Class HttpMessageReader

source code


Reads HTTP message from socket.

Instance Methods [hide private]
 
__init__(self, sock, msg, read_timeout)
Reads an HTTP message from a socket.
source code
string
_ContinueParsing(self, buf, eof)
Main function for HTTP message state machine.
source code
 
_CheckStartLineLength(self, length)
Limits the start line buffer size.
source code
 
_CheckHeaderLength(self, length)
Limits the header buffer size.
source code
 
ParseStartLine(self, start_line)
Parses the start line of a message.
source code
bool
_WillPeerCloseConnection(self)
Evaluate whether peer will close the connection.
source code
 
_ParseHeaders(self)
Parses the headers.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  START_LINE_LENGTH_MAX = None
  HEADER_LENGTH_MAX = None
  PS_START_LINE = "start-line"
  PS_HEADERS = "headers"
  PS_BODY = "entity-body"
  PS_COMPLETE = "complete"
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sock, msg, read_timeout)
(Constructor)

source code 

Reads an HTTP message from a socket.

Parameters:
  • sock (socket) - Socket to be read from
  • msg (http.HttpMessage) - Object for the read message
  • read_timeout (float) - Read timeout for socket
Overrides: object.__init__

_ContinueParsing(self, buf, eof)

source code 

Main function for HTTP message state machine.

Parameters:
  • buf (string) - Receive buffer
  • eof (bool) - Whether we've reached EOF on the socket
Returns: string
Updated receive buffer

_CheckStartLineLength(self, length)

source code 

Limits the start line buffer size.

Parameters:
  • length (int) - Buffer size

_CheckHeaderLength(self, length)

source code 

Limits the header buffer size.

Parameters:
  • length (int) - Buffer size

ParseStartLine(self, start_line)

source code 

Parses the start line of a message.

Must be overridden by subclass.

Parameters:
  • start_line (string) - Start line string

_WillPeerCloseConnection(self)

source code 

Evaluate whether peer will close the connection.

Returns: bool
Whether peer will close the connection

_ParseHeaders(self)

source code 

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.