module documentation
(source)

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 Undocumented
Variable NOT_MODIFIED Undocumented
Variable PRECONDITION_FAILED Undocumented
Variable ACCEPTED Undocumented
Variable BAD_GATEWAY Undocumented
Variable BAD_REQUEST Undocumented
Variable CONFLICT Undocumented
Variable CREATED Undocumented
Variable EXPECTATION_FAILED Undocumented
Variable FORBIDDEN Undocumented
Variable GATEWAY_TIMEOUT Undocumented
Variable GONE Undocumented
Variable HTTP_VERSION_NOT_SUPPORTED Undocumented
Variable INSUFFICIENT_STORAGE_SPACE Undocumented
Variable INTERNAL_SERVER_ERROR Undocumented
Variable LENGTH_REQUIRED Undocumented
Variable MOVED_PERMANENTLY Undocumented
Variable MULTI_STATUS Undocumented
Variable MULTIPLE_CHOICE Undocumented
Variable NO_CONTENT Undocumented
Variable NON_AUTHORITATIVE_INFORMATION Undocumented
Variable NOT_ACCEPTABLE Undocumented
Variable NOT_ALLOWED Undocumented
Variable NOT_EXTENDED Undocumented
Variable NOT_FOUND Undocumented
Variable NOT_IMPLEMENTED Undocumented
Variable OK Undocumented
Variable PARTIAL_CONTENT Undocumented
Variable PAYMENT_REQUIRED Undocumented
Variable PROXY_AUTH_REQUIRED Undocumented
Variable REQUEST_ENTITY_TOO_LARGE Undocumented
Variable REQUEST_TIMEOUT Undocumented
Variable REQUEST_URI_TOO_LONG Undocumented
Variable PERMANENT_REDIRECT Undocumented
Variable REQUESTED_RANGE_NOT_SATISFIABLE Undocumented
Variable RESET_CONTENT Undocumented
Variable RESPONSES Undocumented
Variable SEE_OTHER Undocumented
Variable SERVICE_UNAVAILABLE Undocumented
Variable SWITCHING Undocumented
Variable TEMPORARY_REDIRECT Undocumented
Variable UNAUTHORIZED Undocumented
Variable UNSUPPORTED_MEDIA_TYPE Undocumented
Variable USE_PROXY Undocumented
Variable H2_ENABLED Undocumented
Variable protocol_version Undocumented
Variable weekdayname Undocumented
Variable monthname Undocumented
Variable weekdayname_lower Undocumented
Variable monthname_lower Undocumented
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 BytesIO wrapper that conforms for the transport API. I support the `writeSequence' method.
Class HTTPClient A client for HTTP 1.0.
Variable NO_BODY_CODES Undocumented
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.
Variable _REQUEST_TIMEOUT Undocumented
Function _parseHeader Undocumented
Interface _IDeprecatedHTTPChannelToRequestInterface The interface HTTPChannel expects of Request.
Variable _QUEUED_SENTINEL Undocumented
Function _getContentFile Get a writeable file-like object to which request content can be written.
Variable _hostHeaderExpression Undocumented
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.
CACHED = (source)
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.
(type: str)
FOUND = (source)

Undocumented

(type: int)
NOT_MODIFIED = (source)

Undocumented

(type: int)
PRECONDITION_FAILED = (source)

Undocumented

(type: int)
ACCEPTED = (source)

Undocumented

(type: int)
BAD_GATEWAY = (source)

Undocumented

(type: int)
BAD_REQUEST = (source)

Undocumented

(type: int)
CONFLICT = (source)

Undocumented

(type: int)
CREATED = (source)

Undocumented

(type: int)
EXPECTATION_FAILED = (source)

Undocumented

(type: int)
FORBIDDEN = (source)

Undocumented

(type: int)
GATEWAY_TIMEOUT = (source)

Undocumented

(type: int)
GONE = (source)

Undocumented

(type: int)
HTTP_VERSION_NOT_SUPPORTED = (source)

Undocumented

(type: int)
INSUFFICIENT_STORAGE_SPACE = (source)

Undocumented

(type: int)
INTERNAL_SERVER_ERROR = (source)

Undocumented

(type: int)
LENGTH_REQUIRED = (source)

Undocumented

(type: int)
MOVED_PERMANENTLY = (source)

Undocumented

(type: int)
MULTI_STATUS = (source)

Undocumented

(type: int)
MULTIPLE_CHOICE = (source)

Undocumented

(type: int)
NO_CONTENT = (source)

Undocumented

(type: int)
NON_AUTHORITATIVE_INFORMATION = (source)

Undocumented

(type: int)
NOT_ACCEPTABLE = (source)

Undocumented

(type: int)
NOT_ALLOWED = (source)

Undocumented

(type: int)
NOT_EXTENDED = (source)

Undocumented

(type: int)
NOT_FOUND = (source)

Undocumented

(type: int)
NOT_IMPLEMENTED = (source)

Undocumented

(type: int)

Undocumented

(type: int)
PARTIAL_CONTENT = (source)

Undocumented

(type: int)
PAYMENT_REQUIRED = (source)

Undocumented

(type: int)
PROXY_AUTH_REQUIRED = (source)

Undocumented

(type: int)
REQUEST_ENTITY_TOO_LARGE = (source)

Undocumented

(type: int)
REQUEST_TIMEOUT = (source)

Undocumented

(type: int)
REQUEST_URI_TOO_LONG = (source)

Undocumented

(type: int)
PERMANENT_REDIRECT = (source)

Undocumented

(type: int)
REQUESTED_RANGE_NOT_SATISFIABLE = (source)

Undocumented

(type: int)
RESET_CONTENT = (source)

Undocumented

(type: int)
RESPONSES = (source)

Undocumented

SEE_OTHER = (source)

Undocumented

(type: int)
SERVICE_UNAVAILABLE = (source)

Undocumented

(type: int)
SWITCHING = (source)

Undocumented

(type: int)
TEMPORARY_REDIRECT = (source)

Undocumented

(type: int)
UNAUTHORIZED = (source)

Undocumented

(type: int)
UNSUPPORTED_MEDIA_TYPE = (source)

Undocumented

(type: int)
USE_PROXY = (source)

Undocumented

(type: int)
H2_ENABLED = (source)

Undocumented

(type: bool)
_REQUEST_TIMEOUT = (source)

Undocumented

protocol_version = (source)

Undocumented

(type: str)
weekdayname = (source)

Undocumented

(type: list[str])
monthname = (source)

Undocumented

(type: list)
weekdayname_lower = (source)

Undocumented

monthname_lower = (source)

Undocumented

def _parseHeader(line): (source)

Undocumented

def urlparse(url): (source)

Parse an URL into six components.

This is similar to urlparse.urlparse, but rejects str input and always produces bytes output.

ParametersurlUndocumented (type: bytes)
ReturnsThe scheme, net location, path, params, query string, and fragment of the URL - all as bytes. (type: ParseResultBytes)
RaisesTypeErrorThe given url was a str string instead of a bytes.
def parse_qs(qs, keep_blank_values=0, strict_parsing=0): (source)

Like cgi.parse_qs, but with support for parsing byte strings on Python 3.

ParametersqsUndocumented (type: bytes)
keep_blank_valuesUndocumented
strict_parsingUndocumented
def datetimeToString(msSinceEpoch=None): (source)

Convert seconds since epoch to HTTP datetime string.

ReturnsUndocumented (type: bytes)
def datetimeToLogString(msSinceEpoch=None): (source)

Convert seconds since epoch to log datetime string.

ReturnsUndocumented (type: str)
def timegm(year, month, day, hour, minute, second): (source)

Convert time tuple in GMT to seconds since epoch, GMT

def stringToDatetime(dateString): (source)

Convert an HTTP date string (one of three formats) to seconds since epoch.

ParametersdateStringUndocumented (type: bytes)
def toChunk(data): (source)

Convert string to a chunk.

ParametersdataUndocumented (type: bytes)
Returnsa tuple of bytes representing the chunked encoding of data
def fromChunk(data): (source)

Convert chunk to string.

ParametersdataUndocumented (type: bytes)
Returnstuple of (result, remaining) - both bytes.
RaisesValueErrorIf the given data is not a correctly formatted chunked byte string.
def parseContentRange(header): (source)

Parse a content-range header into (start, end, realLength).

realLength might be None if real length is not known ('*').

NO_BODY_CODES = (source)

Undocumented

(type: tuple[int, ...])
_QUEUED_SENTINEL = (source)

Undocumented

def _getContentFile(length): (source)

Get a writeable file-like object to which request content can be written.

_hostHeaderExpression = (source)

Undocumented

def _escape(s): (source)

Return a string like python repr, but always escaped as if surrounding quotes were double quotes.

ParameterssThe string to escape. (type: bytes or str)
ReturnsAn escaped string. (type: str)
@provider(IAccessLogFormatter)
def combinedLogFormatter(timestamp, request): (source)
ReturnsA combined log formatted log line for the given request.
See AlsoIAccessLogFormatter
@provider(IAccessLogFormatter)
def proxiedLogFormatter(timestamp, request): (source)
ReturnsA 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 AlsoIAccessLogFormatter
def _genericHTTPChannelProtocolFactory(self): (source)

Returns an appropriately initialized _GenericHTTPChannelProtocol.

API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.