protocol.http.redirect
Module¶
Redirection tracking.
-
class
wpull.protocol.http.redirect.
RedirectTracker
(max_redirects=20, codes=(301, 302, 303), repeat_codes=(307, 308))[source]¶ Bases:
object
Keeps track of HTTP document URL redirects.
Parameters: - max_redirects (int) – The maximum number of redirects to allow.
- codes – The HTTP status codes indicating a redirect where the method can change to “GET”.
- repeat_codes – The HTTP status codes indicating a redirect where the method cannot change and future requests should be repeated.
-
REDIRECT_CODES
= (301, 302, 303)¶
-
REPEAT_REDIRECT_CODES
= (307, 308)¶
-
load
(response)[source]¶ Load the response and increment the counter.
Parameters: response ( http.request.Response
) – The response from a previous request.
-
next_location
(raw=False)[source]¶ Returns the next location.
Parameters: raw (bool) – If True, the original string contained in the Location field will be returned. Otherwise, the URL will be normalized to a complete URL. Returns: If str, the location. Otherwise, no next location. Return type: str, None