Package wtf :: Package impl :: Package http :: Module _request :: Class BaseState
[hide private]
[frames] | no frames]

Class BaseState

source code

object --+
         |
        BaseState
Known Subclasses:

Base state class

Every state method raises a StateError in here. Override implemented function in derived classes.

Instance Methods [hide private]
 
__init__(self, request)
Initialization
source code
 
_set_state(self, state)
(Re)set the request state
source code
tuple
read_request(self)
Read the request line, parse method, url and protocol version
source code
dict
read_headers(self)
Read and parse the headers
source code
dict
request_body_stream(self)
Return a stream for the request body.
source code
 
send_continue(self)
Send 100 Continue intermediate response
source code
 
_send_continue(self)
Actually 100 continue sending impl, for out of state needs
source code
 
send_status(self, status)
Send the response status line
source code
 
send_headers(self, headers)
Send the headers
source code
 
finish_headers(self)
Finish header sending, prepare the response for the body
source code
 
response_body_stream(self)
Retrieve the response body stream
source code

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

Instance Variables [hide private]
bool response_started = None
Was the response already started?
HTTPRequest _request
The request instance
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, request)
(Constructor)

source code 
Initialization
Parameters:
Overrides: object.__init__

_set_state(self, state)

source code 
(Re)set the request state
Parameters:

read_request(self)

source code 
Read the request line, parse method, url and protocol version
Returns: tuple
A tuple of method, url and protocol version (('method', 'url', (major, minor)))
Raises:

read_headers(self)

source code 
Read and parse the headers
Returns: dict
A dict of comma folded headers, keys are lower cased
Raises:

request_body_stream(self)

source code 

Return a stream for the request body.

Chunking and Expect handling are done transparently.

Returns: dict
A stream for the request body

send_status(self, status)

source code 
Send the response status line
Parameters:
  • status (str) - The status line (3 digit code, space, reason)

send_headers(self, headers)

source code 

Send the headers

Actually the headers may be accumulated until finish_headers is called

Parameters:
  • headers (iterable) - List of headers ([('name', 'value'), ...])

finish_headers(self)

source code 

Finish header sending, prepare the response for the body

This function does not guarantee, that headers are actually sent. It might be implemented in a manner that headers are still being modified, when the first body chunk comes in (but they all must be flushed then).