Known subclasses: twisted.web.client.BrowserLikeRedirectAgent

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.

ParametersredirectLimitThe maximum number of times the agent is allowed to follow redirects before failing with a error.InfiniteRedirection.
Present Since11.1
Method __init__ Undocumented
Method request Send a client request following HTTP redirects.
Class Variable _redirectResponses A list of HTTP status codes to be redirected for GET and HEAD methods.
Class Variable _seeOtherResponses A list of HTTP status codes to be redirected for any method and the method altered to GET.
Method _resolveLocation Resolve the redirect location against the request URI.
Method _handleRedirect Handle a redirect response, checking the number of redirects already followed, and extracting the location header fields.
Method _handleResponse Handle the response, making another request if it indicates a redirect.
_redirectResponses =
A list of HTTP status codes to be redirected for GET and HEAD methods.
_seeOtherResponses =
A list of HTTP status codes to be redirected for any method and the method altered to GET.
def __init__(self, agent, redirectLimit=20): (source)
Undocumented
def request(self, method, uri, headers=None, bodyProducer=None): (source)

Send a client request following HTTP redirects.

See AlsoAgent.request.
def _resolveLocation(self, requestURI, location): (source)

Resolve the redirect location against the request URI.

ParametersrequestURIThe request URI. (type: bytes)
locationThe redirect location. (type: bytes)
ReturnsFinal resolved URI. (type: bytes)
def _handleRedirect(self, response, method, uri, headers, redirectCount): (source)

Handle a redirect response, checking the number of redirects already followed, and extracting the location header fields.

def _handleResponse(self, response, method, uri, headers, redirectCount): (source)

Handle the response, making another request if it indicates a redirect.

API Documentation for Twisted, generated by pydoctor at 2016-08-28 08:46:05.