class CookieAgent: (source)
Constructor: CookieAgent(agent, cookieJar)
Implements interfaces: twisted.web.iweb.IAgent
CookieAgent extends the basic Agent to add RFC-compliant handling of HTTP cookies. Cookies are written to and extracted from a CookieJar instance.
The same cookie jar instance will be used for any requests through this agent, mutating it whenever a Set-Cookie header appears in a response.
| Present Since | |
| 11.1 |
| Method | __init__ |
Undocumented |
| Method | request |
Issue a new request to the wrapped Agent. |
| Instance Variable | cookie |
Initialized cookie jar to read cookies from and store cookies to. |
| Method | _extract |
Extract response cookies and store them in the cookie jar. |
| Instance Variable | _agent |
Underlying Twisted Web agent to issue requests through. |
bytes, uri: bytes, headers: Optional[ Headers] = None, bodyProducer: Optional[ IBodyProducer] = None) -> Deferred[ IResponse]:
(source)
¶
Issue a new request to the wrapped Agent.
Send a Cookie header if a cookie for uri is stored in CookieAgent.cookieJar. Cookies are automatically extracted and stored from requests.
If a 'cookie' header appears in headers it will override the automatic cookie header obtained from the cookie jar.
| See Also | |
Agent.request |
IResponse, request: _FakeStdlibRequest) -> IResponse:
(source)
¶
Extract response cookies and store them in the cookie jar.
| Parameters | |
response:IResponse | the Twisted Web response that we are processing. |
request:_FakeStdlibRequest | A _FakeStdlibRequest wrapping our Twisted request, for CookieJar to extract cookies from. |
| Returns | |
IResponse | Undocumented |