HyperText Transfer Protocol implementation.
This is the basic server-side protocol implementation used by the Twisted Web server. It can parse HTTP 1.0 requests and supports many HTTP 1.1 features as well. Additionally, some functionality implemented here is also useful for HTTP clients (such as the chunked encoding parser).
Variable | CACHED | A marker value to be returned from cache-related request methods to indicate to the caller that a cached response will be usable and no response body should be generated. |
Variable | FOUND | An HTTP response code indicating a temporary redirect. |
Variable | NOT_MODIFIED | An HTTP response code indicating that a requested pre-condition (for example, the condition represented by an If-Modified-Since header is present in the request) has succeeded. This indicates a response body cached by the client can be used. |
Variable | PRECONDITION_FAILED | An HTTP response code indicating that a requested pre-condition (for example, the condition represented by an If-None-Match header is present in the request) has failed. This should typically indicate that the server has not taken the requested action. |
Function | urlparse | Parse an URL into six components. |
Function | parse_qs | Like cgi.parse_qs , but with support for parsing byte
strings on Python 3. |
Function | datetimeToString | Convert seconds since epoch to HTTP datetime string. |
Function | datetimeToLogString | Convert seconds since epoch to log datetime string. |
Function | timegm | Convert time tuple in GMT to seconds since epoch, GMT |
Function | stringToDatetime | Convert an HTTP date string (one of three formats) to seconds since epoch. |
Function | toChunk | Convert string to a chunk. |
Function | fromChunk | Convert chunk to string. |
Function | parseContentRange | Parse a content-range header into (start, end, realLength). |
Class | StringTransport | I am a StringIO wrapper that conforms for the transport API. I support the `writeSequence' method. |
Class | HTTPClient | A client for HTTP 1.0. |
Class | Request | A HTTP request. |
Class | PotentialDataLoss | No summary |
Class | HTTPChannel | A receiver for HTTP requests. |
Function | combinedLogFormatter | |
Function | proxiedLogFormatter | |
Class | HTTPFactory | Factory for HTTP server. |
Function | _parseHeader | Undocumented |
Interface | _IDeprecatedHTTPChannelToRequestInterface | The interface HTTPChannel
expects of Request . |
Function | _getContentFile | Get a writeable file-like object to which request content can be written. |
Class | _DataLoss | No summary |
Class | _MalformedChunkedDataError | No summary |
Class | _IdentityTransferDecoder | Protocol for accumulating bytes up to a specified length. This handles the case where no Transfer-Encoding is specified. |
Class | _ChunkedTransferDecoder | No summary |
Class | _NoPushProducer | A no-op version of interfaces.IPushProducer ,
used to abstract over the possibility that a HTTPChannel
transport does not provide IPushProducer . |
Function | _escape | Return a string like python repr, but always escaped as if surrounding quotes were double quotes. |
Class | _XForwardedForAddress | IAddress
which represents the client IP to log for a request, as gleaned from an
X-Forwarded-For header. |
Class | _XForwardedForRequest | Add a layer on top of another request that only uses the value of an
X-Forwarded-For header as the result of getClientAddress . |
Class | _GenericHTTPChannelProtocol | A proxy object that wraps one of the HTTP protocol objects, and switches between them depending on TLS negotiated protocol. |
Function | _genericHTTPChannelProtocolFactory | Returns an appropriately initialized _GenericHTTPChannelProtocol. |
Parse an URL into six components.
This is similar to urlparse.urlparse
, but rejects
unicode
input and always produces bytes
output.
Returns | The scheme, net location, path, params, query string, and fragment of the
URL - all as bytes . (type: ParseResultBytes ) | |
Raises | TypeError | The given url was a unicode string instead of a
bytes . |
Like cgi.parse_qs
, but with support for parsing byte
strings on Python 3.
Convert seconds since epoch to HTTP datetime string.
Returns | (type: bytes ) |
Convert seconds since epoch to log datetime string.
Returns | (type: str ) |
Convert time tuple in GMT to seconds since epoch, GMT
Convert an HTTP date string (one of three formats) to seconds since epoch.
Convert string to a chunk.
Returns | a tuple of bytes representing the chunked encoding of data |
Convert chunk to string.
Returns | tuple of (result, remaining) - both bytes . | |
Raises | ValueError | If the given data is not a correctly formatted chunked byte string. |
Parse a content-range header into (start, end, realLength).
realLength might be None if real length is not known ('*').
Get a writeable file-like object to which request content can be written.
Returns | A combined log formatted log line for the given request. | |
See Also | IAccessLogFormatter |
Returns | A combined log formatted log line for the given request but use the value of the X-Forwarded-For header as the value for the client IP address. | |
See Also | IAccessLogFormatter |