| |
- io.HTTPServer.HandlerResolver
- io.HTTPServer.Request
- io.HTTPServer.RequestHandler
-
- io.HTTPServer.BufferedResponseHandler
-
- io.HTTPServer.BasicErrorHandler
- io.HTTPServer.HTTPCGIAdapter
- spug.io.proactor.ConnectHandler
-
- io.HTTPServer.HTTPConnectHandler
- spug.io.proactor.DataHandler
-
- io.HTTPServer.HTTPDataHandler
class BufferedResponseHandler(RequestHandler) |
|
A request handler that works nicely for pages that are small enough to
be stored in an buffer in memory (so pretty much anything). You should
avoid using it for pages that need to be read from disk (or any other
device) because these should really be dealt with as an object in the
proactor. |
|
Methods defined here:
- __init__(self, output)
- Constructs the request handler from the entire output buffer.
parms:
output::
[string]
- get(self, size)
- put(self, data)
- readyToClose(self)
- readyToGet(self)
Methods inherited from RequestHandler:
- getCode(self)
- Returns the HTTP response code (an integer). The base class
implementation always returns 200.
May be overriden by derived classes, usually to return an error code.
- getMessage(self)
- Returns the HTTP response message (a string). The base class
implementation always returns "OK".
May be overriden by derived classes, usually to return an error
message.
- readyToPut(self)
|
class HTTPCGIAdapter(RequestHandler) |
|
Serves as a RequestHandler for spug.web CGI objects. |
|
Methods defined here:
- __init__(self, req, manager)
- parms:
req::
[@Request] The HTTP request.
manager::
[@spug.web.cgi.CGIManager] the CGI manager to receive the
request. Actually, this need not be a CGIManager, but can be
any object that implements process(CGIRequest, CGIResponse)
- get(self, size)
- put(self, data)
- readyToClose(self)
- readyToGet(self)
- readyToPut(self)
Data and other attributes defined here:
- PROCESSING = 1
- READING = 0
- WRITING = 2
Methods inherited from RequestHandler:
- getCode(self)
- Returns the HTTP response code (an integer). The base class
implementation always returns 200.
May be overriden by derived classes, usually to return an error code.
- getMessage(self)
- Returns the HTTP response message (a string). The base class
implementation always returns "OK".
May be overriden by derived classes, usually to return an error
message.
|
class HTTPDataHandler(spug.io.proactor.DataHandler) |
| |
Methods defined here:
- __init__(self, handlerResolver)
- get(self, size)
- peek(self, size)
- put(self, data)
- readyToClose(self)
- readyToGet(self)
- readyToPut(self)
Data and other attributes defined here:
- GOT_FIRST_LINE = 1
- GOT_HEADERS = 2
- GOT_REQUEST = 3
- INIT = 0
Methods inherited from spug.io.proactor.DataHandler:
- handleConnect(self)
- Called by Proactor when the connection is fully initialized.
May be overriden, base class version does nothing.
TODO: call this!!
- handleDisconnect(self)
- Called by Proactor when the connection disconnects.
The handler should not attempt to deregister the object from the
proactor - this will be done automatically by the proactor.
May be implemented by derived classes, base class implementation does
nothing.
- handleError(self)
- Called by Proactor when an error occurs on the stream.
May be implemented by derived classes, base class implementation
deregisters.
|
class Request |
|
Public-vars:
method::
[string] The HTTP method (GET, PUT ...)
path::
[string] the resource path (as obtained from the request line)
headers::
[dict<string, string>] the request headers. Header names are
converted to lower case. |
|
Methods defined here:
- __init__(self, method, path)
- setHeader(self, header, value)
- Sets the header to the value in the 'headers' dict, doing case
normalization on the header.
parms:
header::
[string]
value::
[string]
|
class RequestHandler |
|
(Mostly) abstract interface for a request handler. This very closely
follows the interface for @spug.io.proactor.DataHandler, except that it
doesn't follow the peek\/get paradigm. The HTTPDataHandler will call
@get() to pull data for peek and hold it until the subsequent get. |
|
Methods defined here:
- get(self, size)
- getCode(self)
- Returns the HTTP response code (an integer). The base class
implementation always returns 200.
May be overriden by derived classes, usually to return an error code.
- getMessage(self)
- Returns the HTTP response message (a string). The base class
implementation always returns "OK".
May be overriden by derived classes, usually to return an error
message.
- put(self, data)
- Puts data into the handler. This will only be called for the post
method, and then for only as much data as is in the "content-length"
header. If there is no content-length header, it will be called
until the close of the connection.
- readyToClose(self)
- readyToGet(self)
- readyToPut(self)
| |