twisted.web.test.requesthelper.DummyRequest(object)
class documentationtwisted.web.test.requesthelper
(View In Hierarchy)
Known subclasses: twisted.web.test.test_web.DummyRequestForLogTest
Represents a dummy or fake request. See twisted.web.server.Request
.
Instance Variable | requestheaders | A Headers instance that stores values for all request headers. (type: Headers ) |
Instance Variable | responseHeaders | A Headers instance that stores values for all response headers. (type: Headers ) |
Instance Variable | responseCode | The response code which was passed to setResponseCode . (type: int ) |
Instance Variable | written | The bytes which have been written to the request. (type: list of bytes ) |
Method | registerProducer | Call an IPullProducer 's
resumeProducing method in a loop until it unregisters
itself. |
Method | unregisterProducer | Undocumented |
Method | __init__ | Undocumented |
Method | getAllHeaders | Return dictionary mapping the names of all received headers to the last value received for each. |
Method | getHeader | Retrieve the value of a request header. |
Method | setHeader | TODO: make this assert on write() if the header is content-length |
Method | getSession | Undocumented |
Method | render | Render the given resource as a response to this request. |
Method | write | 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 | finish | Record that the request is finished and callback and Deferred s
waiting for notification of this. |
Method | processingFailed | Errback and Deferreds waiting for finish notification. |
Method | addArg | Undocumented |
Method | setResponseCode | Set the HTTP status response code, but takes care that this is called before any data is written. |
Method | setLastModified | Undocumented |
Method | setETag | Undocumented |
Method | getClientIP | Return the IPv4 address of the client which made this request, if there
is one, otherwise None . |
Method | getClientAddress | Return the IAddress
of the client that made this request. |
Method | getRequestHostname | Get a dummy hostname associated to the HTTP request. |
Method | getHost | Get a dummy transport's host. |
Method | setHost | Change the host and port the request thinks it's using. |
Method | redirect | Utility function that does a redirect. |
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. |
Call an IPullProducer
's
resumeProducing
method in a loop until it unregisters
itself.
Parameters | prod | The producer. (type: IPullProducer ) |
s | Whether or not the producer is streaming. |
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
.
Retrieve the value of a request header.
Parameters | name | The name of the request header for which to retrieve the value. Header
names are compared case-insensitively. (type: bytes ) |
Returns | The value of the specified request header. (type: bytes or None ) |
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.
Record that the request is finished and callback and Deferred
s
waiting for notification of this.
Set the HTTP status response code, but takes care that this is called before any data is written.
Return the IPv4 address of the client which made this request, if there
is one, otherwise None
.
Get a dummy hostname associated to the HTTP request.
Returns | a dummy hostname (type: bytes ) |
Change the host and port the request thinks it's using.
Parameters | host | The value to which to change the host header. (type: bytes ) |
ssl | A flag which, if True , indicates that the request is
considered secure (if True , isSecure
will return True ). (type: bool ) |