t.w.http : module documentation

Part of twisted.web2 View Source

HyperText Transfer Protocol implementation.

The second coming.

Maintainer: James Y Knight
Function splitHostPort Split the host in "host:port" format into host and port fields. If port was not specified, use the default for the given scheme, if known. Returns a tuple of (hostname, portnumber).
Function parseVersion Parse version strings of the form Protocol '/' Major '.' Minor. E.g. 'HTTP/1.1'. Returns (protocol, major, minor). Will raise ValueError on bad syntax.
Class HTTPError No class docstring; 1/2 methods documented
Class Response An object representing an HTTP Response to be sent to the client.
Class StatusResponse A Response object which simply contains a status code and a description of what happened.
Class RedirectResponse A Response object that contains a redirect to another network location.
Function NotModifiedResponse Undocumented
Function checkPreconditions Check to see if this request passes the conditional checks specified by the client. May raise an HTTPError with result codes NOT_MODIFIED or PRECONDITION_FAILED, as appropriate.
Function checkIfRange Checks for the If-Range header, and if it exists, checks if the test passes. Returns true if the server should return partial data.
Class Request A HTTP request.
Class _NotifyingProducerStream Undocumented
def splitHostPort(scheme, hostport): (source)
Split the host in "host:port" format into host and port fields. If port was not specified, use the default for the given scheme, if known. Returns a tuple of (hostname, portnumber).
def parseVersion(strversion): (source)
Parse version strings of the form Protocol '/' Major '.' Minor. E.g. 'HTTP/1.1'. Returns (protocol, major, minor). Will raise ValueError on bad syntax.
def NotModifiedResponse(oldResponse=None): (source)
Undocumented
def checkPreconditions(request, response=None, entityExists=True, etag=None, lastModified=None): (source)

Check to see if this request passes the conditional checks specified by the client. May raise an HTTPError with result codes NOT_MODIFIED or PRECONDITION_FAILED, as appropriate.

This function is called automatically as an output filter for GET and HEAD requests. With GET/HEAD, it is not important for the precondition check to occur before doing the action, as the method is non-destructive.

However, if you are implementing other request methods, like PUT for your resource, you will need to call this after determining the etag and last-modified time of the existing resource but before actually doing the requested action. In that case,

This examines the appropriate request headers for conditionals, (If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match, or If-Range), compares with the etag and last and and then sets the response code as necessary.
ParametersresponseThis should be provided for GET/HEAD methods. If it is specified, the etag and lastModified arguments will be retrieved automatically from the response headers and shouldn't be separately specified. Not providing the response with a GET request may cause the emitted "Not Modified" responses to be non-conformant.
entityExistsSet to False if the entity in question doesn't yet exist. Necessary for PUT support with 'If-None-Match: *'.
etagThe etag of the resource to check against, or None.
lastModifiedThe last modified date of the resource to check against, or None.
RaisesHTTPError: Raised when the preconditions fail, in order to abort processing and emit an error page.
def checkIfRange(request, response): (source)
Checks for the If-Range header, and if it exists, checks if the test passes. Returns true if the server should return partial data.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:17:34.