Package CyberRail :: Package common :: Module httpclient :: Class Response
[hide private]
[frames] | no frames]

Class Response

source code


A Response is the data the server returns when we request it. It contains headers and a body.

Instance Methods [hide private]
 
__init__(self, request=None, previousResponse=None)
Create a response.
source code
 
__str__(self)
str(x)
source code
 
setIoError(self, error)
In case of io error.
source code
 
clearBody(self)
Clear the body of the response.
source code
 
addToBuffer(self, data)
Add response data to the response buffer.
source code
 
_manageBufferForHeaders(self)
Check if headers are completly arrived
source code
 
_manageBufferForBody(self)
Parse the body for chunked blocks, if any.
source code
 
_checkForBody(self)
Set appropriate state of the response to manage a body.
source code
 
hasBody(self)
Return true if response has a body, or would have, if your request is a HEAD request.
source code
 
hasConnectionClose(self)
Return True if server indicated that connection will be closed
source code
 
getBody(self)
Return the body, or part of it if your are in CALLBACK mode.
source code
 
getHeaders(self)
Return the headers
source code
 
_parseHeaders(self, lines)
Parse the headers in the lines
source code
 
_parseStatusLine(self, line)
Set the status code and string and the version of the server.
source code

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

Class Variables [hide private]
  multiValuedHeaders = []
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, request=None, previousResponse=None)
(Constructor)

source code 

Create a response.

Parameters:
  • previousResponse - the previous response, if the transaction includes more than one response.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

addToBuffer(self, data)

source code 

Add response data to the response buffer. Once all headers are retreived, this buffer only contains body data (if any)

Returns:
True when all responses headers has arrived

_manageBufferForHeaders(self)

source code 

Check if headers are completly arrived

Returns:
True if all headers have been read. In this case, you should no more call this method.

hasBody(self)

source code 

Return true if response has a body, or would have, if your request is a HEAD request.

Note: Remember that even if body length is not known, a body can be sent.

_parseHeaders(self, lines)

source code 

Parse the headers in the lines

Parameters:
  • lines - lines which contain headers

Bug: In this implementation, headers can't be multi-lines.