module documentation
(source)

An HTTP 1.1 client.

The way to use the functionality provided by this module is to:

Various other classes in this module support this usage:

  • HTTPParser is the basic HTTP parser. It can handle the parts of HTTP which are symmetric between requests and responses.
  • HTTPClientParser extends HTTPParser to handle response-specific parts of HTTP. One instance is created for each request to parse the corresponding response.
Class ​Bad​Headers Headers passed to Request were in some way invalid.
Class ​Bad​Response​Version The version string in a status line was unparsable.
Class ​Chunked​Encoder Helper object which exposes IConsumer on top of HTTP11ClientProtocol for streaming request bodies to the server.
Class ​Connection​Aborted The connection was explicitly aborted by application code.
Class ​Excess​Write The body IBodyProducer for a request tried to write data after indicating it had finished writing data.
Class ​HTTP11​Client​Protocol HTTP11ClientProtocol is an implementation of the HTTP 1.1 client protocol. It supports as few features as possible.
Class ​HTTPClient​Parser An HTTP parser which only handles HTTP responses.
Class ​HTTPParser HTTPParser handles the parsing side of HTTP processing. With a suitable subclass, it can parse either the client side or the server side of the connection.
Class ​Length​Enforcing​Consumer An IConsumer proxy which enforces an exact length requirement on the total data written to it.
Class ​Parse​Error Some received data could not be parsed.
Class ​Request A Request instance describes an HTTP request to be sent to an HTTP server.
Class ​Request​Not​Sent No summary
Class ​Transport​Proxy​Producer An twisted.internet.interfaces.IPushProducer implementation which wraps another such thing and proxies calls to it until it is told to stop.
Class ​Wrong​Body​Length An IBodyProducer declared the number of bytes it was going to produce (via its length attribute) and then produced a different number of bytes.
Function make​Stateful​Dispatcher No summary
Constant BODY Undocumented
Constant DONE Undocumented
Constant HEADER Undocumented
Constant STATUS Undocumented
Class _​Wrapper​Exception _WrapperException is the base exception type for exceptions which include one or more other exceptions as the low-level causes.
Function _call​App​Function Call function. If it raises an exception, log it with a minimal description of the source.
Function _ensure​Valid​Method An HTTP method is an HTTP token, which consists of any visible ASCII character that is not a delimiter (i.e. one of "(),/:;<=>?@[\]{}.)
Function _ensure​Valid​URI A valid URI cannot contain control characters (i.e., characters between 0-32, inclusive and 127) or non-ASCII characters (i.e., characters with values between 128-255, inclusive).
Constant _VALID​_METHOD Undocumented
Constant _VALID​_URI Undocumented
Variable _​Client​Request​Proxy Undocumented
Variable _module​Log Undocumented
def makeStatefulDispatcher(name, template): (source)
Given a dispatch name and a function, return a function which can be used as a method and which, when called, will call another method defined on the instance and return the result. The other method which is called is determined by the value of the _state attribute of the instance.
Parameters
nameA string which is used to construct the name of the subsidiary method to invoke. The subsidiary method is named like '_%s_%s' % (name, _state).
templateA function object which is used to give the returned function a docstring.
Returns
The dispatcher function.
BODY: str = (source)

Undocumented

Value
'BODY'
DONE: str = (source)

Undocumented

Value
'DONE'
HEADER: str = (source)

Undocumented

Value
'HEADER'
STATUS: str = (source)

Undocumented

Value
'STATUS'
def _callAppFunction(function): (source)
Call function. If it raises an exception, log it with a minimal description of the source.
Returns
None
def _ensureValidMethod(method): (source)
An HTTP method is an HTTP token, which consists of any visible ASCII character that is not a delimiter (i.e. one of "(),/:;<=>?@[\]{}.)
Parameters
method:bytesthe method to check
Returns
bytesthe method if it is valid
Raises
ValueErrorif the method is not valid
See Also
https://tools.ietf.org/html/rfc7230#section-3.1.1, https://tools.ietf.org/html/rfc7230#section-3.2.6, https://tools.ietf.org/html/rfc5234#appendix-B.1
def _ensureValidURI(uri): (source)
A valid URI cannot contain control characters (i.e., characters between 0-32, inclusive and 127) or non-ASCII characters (i.e., characters with values between 128-255, inclusive).
Parameters
uri:bytesthe URI to check
Returns
bytesthe URI if it is valid
Raises
ValueErrorif the URI is not valid
See Also
https://tools.ietf.org/html/rfc3986#section-3.3, https://tools.ietf.org/html/rfc3986#appendix-A, https://tools.ietf.org/html/rfc5234#appendix-B.1
_VALID_METHOD = (source)

Undocumented

Value
re.compile(b'\\A[%s]+\\Z'%(bytes().join((b'!',
                                         b'#',
                                         b'$',
                                         b'%',
                                         b'&',
                                         b''',
                                         b'*',
...
_VALID_URI = (source)

Undocumented

Value
re.compile(rb'\A[!-~]+\Z')
_ClientRequestProxy = (source)

Undocumented

_moduleLog = (source)

Undocumented