class documentation

Represents a dummy or fake request. See twisted.web.server.Request.

Method __init__ Undocumented
Method addArg Undocumented
Method finish Record that the request is finished and callback and Deferreds waiting for notification of this.
Method getAllHeaders Return dictionary mapping the names of all received headers to the last value received for each.
Method getClientAddress Return the IAddress of the client that made this request.
Method getClientIP Return the IPv4 address of the client which made this request, if there is one, otherwise None.
Method getHeader Retrieve the value of a request header.
Method getHost Get a dummy transport's host.
Method getRequestHostname Get a dummy hostname associated to the HTTP request.
Method getSession Undocumented
Method notifyFinish Return a Deferred which is called back with None when the request is finished. This will probably only work if you haven't called finish yet.
Method processingFailed Errback and Deferreds waiting for finish notification.
Method redirect Utility function that does a redirect.
Method registerProducer Call an IPullProducer's resumeProducing method in a loop until it unregisters itself.
Method render Render the given resource as a response to this request.
Method setETag Undocumented
Method setHeader TODO: make this assert on write() if the header is content-length
Method setHost Change the host and port the request thinks it's using.
Method setLastModified Undocumented
Method setResponseCode Set the HTTP status response code, but takes care that this is called before any data is written.
Method unregisterProducer Undocumented
Method write Undocumented
Class Variable client Undocumented
Class Variable method Undocumented
Class Variable uri Undocumented
Instance Variable args Undocumented
Instance Variable clientproto Undocumented
Instance Variable finished Undocumented
Instance Variable go Undocumented
Instance Variable postpath Undocumented
Instance Variable prepath Undocumented
Instance Variable protoSession Undocumented
Instance Variable requestheaders A Headers instance that stores values for all request headers.
Instance Variable requestHeaders Undocumented
Instance Variable responseCode The response code which was passed to setResponseCode.
Instance Variable responseHeaders A Headers instance that stores values for all response headers.
Instance Variable responseMessage Undocumented
Instance Variable session Undocumented
Instance Variable sitepath Undocumented
Instance Variable written The bytes which have been written to the request.
Instance Variable _finishedDeferreds None or a list of Deferreds which will be called back with None when finish is called or which will be errbacked if processingFailed is called.
Instance Variable _forceSSL Undocumented
Instance Variable _serverName Undocumented
def __init__(self, postpath, session=None, client=None): (source)

Undocumented

Parameters
postpath:list[bytes]Undocumented
session:Optional[Session]Undocumented
client:Optional[IAddress]Undocumented
def addArg(self, name, value): (source)

Undocumented

def finish(self): (source)

Record that the request is finished and callback and Deferreds waiting for notification of this.

def getAllHeaders(self): (source)

Return dictionary mapping the names of all received headers to the last value received for each.

Since this method does not return all header information, self.requestHeaders.getAllRawHeaders() may be preferred.

NOTE: This function is a direct copy of twisted.web.http.Request.getAllRawHeaders.

def getClientAddress(self): (source)

Return the IAddress of the client that made this request.

Returns
an IAddress provider.an address.
def getClientIP(self): (source)
Deprecated since version 18.4.0: getClientIP was deprecated in Twisted 18.4.0; please use getClientAddress instead.

Return the IPv4 address of the client which made this request, if there is one, otherwise None.

def getHeader(self, name): (source)

Retrieve the value of a request header.

Parameters
name:bytesThe name of the request header for which to retrieve the value. Header names are compared case-insensitively.
Returns
bytes or NoneThe value of the specified request header.
def getHost(self): (source)

Get a dummy transport's host.

Returns
IPv4Addressa dummy transport's host
def getRequestHostname(self): (source)

Get a dummy hostname associated to the HTTP request.

Returns
bytesa dummy hostname
def getSession(self, sessionInterface=None): (source)

Undocumented

def notifyFinish(self): (source)

Return a Deferred which is called back with None when the request is finished. This will probably only work if you haven't called finish yet.

Returns
Deferred[None]Undocumented
def processingFailed(self, reason): (source)

Errback and Deferreds waiting for finish notification.

def redirect(self, url): (source)

Utility function that does a redirect.

The request should have finish() called after this.

def registerProducer(self, prod, s): (source)

Call an IPullProducer's resumeProducing method in a loop until it unregisters itself.

Parameters
prod:IPullProducerThe producer.
sWhether or not the producer is streaming.
def render(self, resource): (source)

Render the given resource as a response to this request.

This implementation only handles a few of the most common behaviors of resources. It can handle a render method that returns a string or NOT_DONE_YET. It doesn't know anything about the semantics of request methods (eg HEAD) nor how to set any particular headers. Basically, it's largely broken, but sufficient for some tests at least. It should not be expanded to do all the same stuff Request does. Instead, DummyRequest should be phased out and Request (or some other real code factored in a different way) used.

def setETag(self, tag): (source)

Undocumented

def setHeader(self, name, value): (source)

TODO: make this assert on write() if the header is content-length

def setHost(self, host, port, ssl=0): (source)

Change the host and port the request thinks it's using.

Parameters
host:bytesThe value to which to change the host header.
portUndocumented
ssl:boolA flag which, if True, indicates that the request is considered secure (if True, isSecure will return True).
def setLastModified(self, when): (source)

Undocumented

def setResponseCode(self, code, message=None): (source)

Set the HTTP status response code, but takes care that this is called before any data is written.

def unregisterProducer(self): (source)

Undocumented

def write(self, data): (source)

Undocumented

Undocumented

Undocumented

finished = (source)

Undocumented

Undocumented

postpath = (source)

Undocumented

Undocumented

protoSession = (source)

Undocumented

requestheaders: Headers = (source)

A Headers instance that stores values for all request headers.

requestHeaders = (source)

Undocumented

responseCode: int = (source)

The response code which was passed to setResponseCode.

responseHeaders: Headers = (source)

A Headers instance that stores values for all response headers.

responseMessage = (source)

Undocumented

Undocumented

sitepath: list = (source)

Undocumented

written: list of bytes = (source)

The bytes which have been written to the request.

_finishedDeferreds = (source)

None or a list of Deferreds which will be called back with None when finish is called or which will be errbacked if processingFailed is called.

_forceSSL = (source)

Undocumented

_serverName: bytes = (source)

Undocumented