class documentation

A Request instance describes an HTTP request to be sent to an HTTP server.

Method __init__ No summary
Method stopWriting Stop writing this request to the transport. This can only be called after writeTo and before the Deferred returned by writeTo fires. It should cancel any asynchronous task started by writeTo. The Deferred...
Method writeTo Format this Request as an HTTP/1.1 request and write it to the given transport. If bodyProducer is not None, it will be associated with an IConsumer.
Instance Variable bodyProducer See __init__.
Instance Variable headers See __init__.
Instance Variable method See __init__.
Instance Variable persistent See __init__.
Instance Variable uri See __init__.
Property absoluteURI The absolute URI of the request as bytes, or None if the absolute URI cannot be determined.
Class Method _construct Private constructor.
Method _writeHeaders Undocumented
Method _writeToBodyProducerChunked Write this request to the given transport using chunked transfer-encoding to frame the body.
Method _writeToBodyProducerContentLength Write this request to the given transport using content-length to frame the body.
Method _writeToEmptyBodyContentLength Write this request to the given transport using content-length to frame the (empty) body.
Class Variable _log Undocumented
Instance Variable _parsedURI Parsed URI for the request, or None.
def __init__(self, method, uri, headers, bodyProducer, persistent=False): (source)
Parameters
method:bytesThe HTTP method for this request, ex: b'GET', b'HEAD', b'POST', etc.
uri:bytesThe relative URI of the resource to request. For example, b'/foo/bar?baz=quux'.
headers:twisted.web.http_headers.HeadersHeaders to be sent to the server. It is important to note that this object does not create any implicit headers. So it is up to the HTTP Client to add required headers such as 'Host'.
bodyProducerNone or an IBodyProducer provider which produces the content body to send to the remote HTTP server.
persistent:boolSet to True when you use HTTP persistent connection, defaults to False.
def stopWriting(self): (source)

Stop writing this request to the transport. This can only be called after writeTo and before the Deferred returned by writeTo fires. It should cancel any asynchronous task started by writeTo. The Deferred returned by writeTo need not be fired if this method is called.

def writeTo(self, transport): (source)

Format this Request as an HTTP/1.1 request and write it to the given transport. If bodyProducer is not None, it will be associated with an IConsumer.

Parameters
transport:twisted.internet.interfaces.ITransport providerThe transport to which to write.
Returns
A Deferred which fires with None when the request has been completely written to the transport or with a Failure if there is any problem generating the request bytes.
bodyProducer = (source)
persistent = (source)
@property
absoluteURI = (source)

The absolute URI of the request as bytes, or None if the absolute URI cannot be determined.

@classmethod
def _construct(cls, method, uri, headers, bodyProducer, persistent=False, parsedURI=None): (source)

Private constructor.

Parameters
methodSee __init__.
uriSee __init__.
headersSee __init__.
bodyProducerSee __init__.
persistentSee __init__.
parsedURISee Request._parsedURI.
Returns
Request instance.
def _writeHeaders(self, transport, TEorCL): (source)

Undocumented

def _writeToBodyProducerChunked(self, transport): (source)

Write this request to the given transport using chunked transfer-encoding to frame the body.

Parameters
transportSee writeTo.
Returns
See writeTo.
def _writeToBodyProducerContentLength(self, transport): (source)

Write this request to the given transport using content-length to frame the body.

Parameters
transportSee writeTo.
Returns
See writeTo.
def _writeToEmptyBodyContentLength(self, transport): (source)

Write this request to the given transport using content-length to frame the (empty) body.

Parameters
transportSee writeTo.
Returns
See writeTo.

Undocumented

Parsed URI for the request, or None.