twisted :: web :: server :: Request :: Class Request
[hide private]

classobj Request

 spread.jelly.Jellyable --+        
                          |        
spread.flavors.Serializable --+    
                              |    
        spread.flavors.Copyable --+
                                  |
                   http.Request --+
                                  |
python.components.Componentized --+
                                  |
                                 Request
Known Subclasses:

An HTTP request.

Instance Methods [hide private]
 
URLPath(self)
 
__init__(self, *args, **kw)
 
__provides__(...)
Special descriptor for class ``__provides__``
 
_handleStar(self)
Handle receiving a request whose path is '*'.
 
_log(...)
A logger instance for request related messages.
 
_prePathURL(self, prepath)
 
childLink(self, name)
Return the text that links to a child of the requested resource.
 
finish(self)
Override http.Request.finish for possible encoding.
 
getRootURL(self)
Get a previously-remembered URL.
 
getSession(self, sessionInterface=None, forceNotSecure=False)
Check if there is a session cookie, and if not, create it.
 
getStateToCopyFor(self, issuer)
Gather state to send when I am serialized for a particular perspective.
 
prePathURL(self)
 
process(self)
Process a request.
twisted.python.failure.Failure
processingFailed(self, reason)
Finish this request with an indication that processing failed and possibly display a traceback.
 
rememberRootURL(self)
Remember the currently-processed part of the URL for later recalling.
 
render(self, resrc)
Ask a resource to render itself.
 
sibLink(self, name)
Return the text that links to a sibling of the requested resource.
 
view_addCookie(self, issuer, k, v, **kwargs)
Remote version of addCookie; same interface.
 
view_finish(self, issuer)
Remote version of finish; same interface.
 
view_registerProducer(self, issuer, producer, streaming)
Remote version of registerProducer; same interface.
 
view_setETag(self, issuer, tag)
Remote version of setETag; same interface.
 
view_setHeader(self, issuer, k, v)
Remote version of setHeader; same interface.
 
view_setLastModified(self, issuer, when)
Remote version of setLastModified; same interface.
 
view_setResponseCode(self, issuer, code, message=None)
Remote version of setResponseCode; same interface.
 
view_unregisterProducer(self, issuer)
 
view_write(self, issuer, data)
Remote version of write; same interface.
 
write(self, data)
Write data to the transport (if not responding to a HEAD request).

Inherited from spread.flavors.Copyable: getStateToCopy, getTypeToCopy, getTypeToCopyFor, jellyFor

Inherited from spread.flavors.Serializable: processUniqueID

Inherited from spread.jelly.Jellyable: __providedBy__, getStateFor

Inherited from http.Request: __eq__, __hash__, __ne__, __repr__, addCookie, connectionLost, getAllHeaders, getClientAddress, getClientIP, getCookie, getHeader, getHost, getPassword, getRequestHostname, getUser, gotLength, handleContentChunk, isSecure, loseConnection, noLongerQueued, notifyFinish, parseCookies, redirect, registerProducer, requestReceived, setETag, setHeader, setHost, setLastModified, setResponseCode, unregisterProducer

Inherited from http.Request (private): _authorize, _cleanup

Inherited from python.components.Componentized: __conform__, addAdapter, addComponent, getComponent, locateAdapterClass, removeComponent, setAdapter, setComponent, unsetComponent

Class Variables [hide private]
  __implemented__ = <implementedBy twisted.web.server.Request>
  __pychecker__ = 'unusednames=issuer'
  _encoder = None
  _inFakeHead = False
  appRootURL = None
  site = None

Inherited from http.Request: chunked, clientproto, code, code_message, content, etag, finished, lastModified, producer, sentLength, startedWriting

Inherited from http.Request (private): _forceSSL

Inherited from python.components.Componentized: persistenceVersion

Instance Variables [hide private]
  _insecureSession = None
The Session object representing state that will be transmitted over plain-text HTTP.
  _secureSession = None
The Session object representing the state that will be transmitted only over HTTPS.
  defaultContentType = 'text/html'
A bytes giving the default Content-Type value to send in responses if no other value is set.

Inherited from http.Request: args, cookies, method, notifications, path, requestHeaders, responseHeaders, uri

Inherited from http.Request (private): _disconnected

Properties [hide private]
Session or None session
If a session has already been created or looked up with Request.getSession, this will return that object.
Method Details [hide private]

__init__(self, *args, **kw)
(Constructor)

 
Parameters:
  • channel - the channel we're connected to.
  • queued - (deprecated) are we in the request queue, or can we start writing to the transport?
Overrides: python.components.Componentized.__init__

__provides__(...)

 
Special descriptor for class ``__provides__``

The descriptor caches the implementedBy info, so that
we can get declarations for objects without instance-specific
interfaces a bit quicker.

Overrides: python.components.Componentized.__provides__

_handleStar(self)

 

Handle receiving a request whose path is '*'.

RFC 7231 defines an OPTIONS * request as being something that a client can send as a low-effort way to probe server capabilities or readiness. Rather than bother the user with this, we simply fast-path it back to an empty 200 OK. Any non-OPTIONS verb gets a 405 Method Not Allowed telling the client they can only use OPTIONS.

_log(...)

 
A logger instance for request related messages.
Parameters:
  • source (object)
  • namespace (str)
Overrides: http.Request._log

finish(self)

 

Override http.Request.finish for possible encoding.

Overrides: http.Request.finish

getSession(self, sessionInterface=None, forceNotSecure=False)

 

Check if there is a session cookie, and if not, create it.

By default, the cookie with be secure for HTTPS requests and not secure for HTTP requests. If for some reason you need access to the insecure cookie from a secure request you can set forceNotSecure = True.

Parameters:
  • forceNotSecure (bool) - Should we retrieve a session that will be transmitted over HTTP, even if this Request was delivered over HTTPS?

getStateToCopyFor(self, issuer)

 

Gather state to send when I am serialized for a particular perspective.

I will default to calling getStateToCopy. Override this to customize this behavior.

Overrides: spread.flavors.Copyable.getStateToCopyFor
(inherited documentation)

process(self)

 

Process a request.

Overrides: http.Request.process

processingFailed(self, reason)

 

Finish this request with an indication that processing failed and possibly display a traceback.

Parameters:
  • reason (twisted.python.failure.Failure) - Reason this request has failed.
Returns: twisted.python.failure.Failure
The reason passed to this method.

render(self, resrc)

 

Ask a resource to render itself.

Parameters:
  • resrc - a twisted.web.resource.IResource.

view_registerProducer(self, issuer, producer, streaming)

 

Remote version of registerProducer; same interface. (requires a remote producer.)

write(self, data)

 

Write data to the transport (if not responding to a HEAD request).

Parameters:
  • data - A string to write to the response.
Overrides: http.Request.write

Instance Variable Details [hide private]

defaultContentType

A bytes giving the default Content-Type value to send in responses if no other value is set. None disables the default.
Value:
'text/html'

Property Details [hide private]

session

If a session has already been created or looked up with Request.getSession, this will return that object. (This will always be the session that matches the security of the request; so if forceNotSecure is used on a secure request, this will not return that session.)

Type:
Session or None