I'm working on a project that uses the Twisted web
facilities, but not the high-level web framework. How can I get access to the HTTPChannel
instance (the twisted protocol
) that created a certain http.Request
instance?
I see that the constructor of http.Request
has the channel as an argument, but there is not method/property that further accesses it.
Also, while I can access the HTTPFactory
instance from the channel via the factory
property - can i access the factory directly from the request instance?
It looks like the channel is available directly on the Request
. Consider Request.__init__
:
def __init__(self, channel, queued):
"""
@param channel: the channel we're connected to.
@param queued: are we in the request queue, or can we start writing to
the transport?
"""
self.notifications = []
self.channel = channel
self.queued = queued
...
self.channel = channel
seems to be just what you're looking for.