class RedirectAgent: (source)
Known subclasses: twisted.web.client.BrowserLikeRedirectAgent
Constructor: RedirectAgent(agent, redirectLimit, sensitiveHeaderNames)
Implements interfaces: twisted.web.iweb.IAgent
An Agent
wrapper which handles HTTP redirects.
The implementation is rather strict: 301 and 302 behaves like 307, not redirecting automatically on methods different from GET and HEAD.
See BrowserLikeRedirectAgent
for a redirecting Agent that behaves more like a web browser.
Parameters | |
redirect | The maximum number of times the agent is allowed to follow redirects before failing with a error.InfiniteRedirection . |
sensitive | An iterable of bytes enumerating the names of headers that must not be transmitted when redirecting to a different origins. These will be consulted in addition to the protocol-specified set of headers that contain sensitive information. |
Present Since | |
11.1 |
Method | __init__ |
Undocumented |
Method | request |
Send a client request following HTTP redirects. |
Method | _handle |
Handle a redirect response, checking the number of redirects already followed, and extracting the location header fields. |
Method | _handle |
Handle the response, making another request if it indicates a redirect. |
Method | _resolve |
Resolve the redirect location against the request URI. |
Class Variable | _redirect |
A list of HTTP status codes to be redirected for GET and HEAD methods. |
Class Variable | _see |
A list of HTTP status codes to be redirected for any method and the method altered to GET. |
Instance Variable | _agent |
Undocumented |
Instance Variable | _redirect |
Undocumented |
Instance Variable | _sensitive |
Undocumented |
IAgent
, redirectLimit: int
= 20, sensitiveHeaderNames: Iterable[ bytes]
= ()):
(source)
¶
Undocumented
Handle a redirect response, checking the number of redirects already followed, and extracting the location header fields.
Resolve the redirect location against the request URI.
Parameters | |
request | The request URI. |
location:bytes | The redirect location. |
Returns | |
bytes | Final resolved URI. |
twisted.web.client.BrowserLikeRedirectAgent
A list
of HTTP status codes to be redirected for GET and HEAD methods.
twisted.web.client.BrowserLikeRedirectAgent
A list
of HTTP status codes to be redirected for any method and the method altered to GET.