requests_proxy_adapter package¶
Submodules¶
requests_proxy_adapter.api module¶
requests_proxy_adapter.api¶
Set of Proxy Transport Adapters for module requests.
-
class
requests_proxy_adapter.api.PrivoxyAdapter(proxy_url, retry_wait=1, retries=3, **kwargs)[source]¶ Bases:
requests.adapters.HTTPAdapterThe transport adapter for Requests to use Privoxy proxy-server with retries when backend errors occurred.
Implements Requests’s
HTTPAdapterAPI.If privoxy backend raises 500 Internal Privoxy Error in suitable cases make retries number of internal retries with delay of retry_wait seconds.
- Parameters
proxy_url (str) – Complete URL-address of Privoxy proxy instance (scheme, host & port).
retry_wait (int) – (optional) Waiting in seconds before next retry if backend raise specified errors. Default 1 second.
retries (int) – (optional) Maximum number of retries. Default 3 times.
kwargs – (optional) Arbitrary keyword arguments for parent class
HTTPAdapter.
-
build_response(req, resp)[source]¶ Builds a
Responseobject from a urllib3 response.Build response are doing by parent class
HTTPAdapter. This code detect 500 in response status code and search in text of response specific strings.- Parameters
req (PreparedRequest) – The
PreparedRequestused to generate the response.resp (HTTPResponse) – The urllib3
HTTPResponseobject.
- Returns
Responseobject- Return type
Response
-
class
requests_proxy_adapter.api.RetryPrivoxyAdapter(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), *args, **kwargs)[source]¶ Bases:
requests_proxy_adapter.api.PrivoxyAdapterThe transport adapter for Requests to use Privoxy proxy-server with retries when backend errors occurred and retries if errors occured on target site by
Retrymodule.Implements Requests’s
HTTPAdapterAPI. Extend classPrivoxyAdapter- Parameters
retries (int) – Total number of retries to allow. Takes precedence over other counts.
backoff_factor (float) – A backoff factor to apply between attempts after the second try (most errors are resolved immediately by a second try without a delay).
status_forcelist (set) – A set of integer HTTP status codes that we should force a retry on.
args – Variable length argument list.
kwargs – Arbitrary keyword arguments.
requests_proxy_adapter.exceptions module¶
requests_proxy_adapter.exceptions¶
This module contains the set of Requests Proxy Adapter’s exceptions.
-
exception
requests_proxy_adapter.exceptions.ConnectionTimeoutError(*args, **kwargs)[source]¶ Bases:
requests_proxy_adapter.exceptions.PrivoxyError4RetryPrivoxy error response contains connection-timeout message.
-
exception
requests_proxy_adapter.exceptions.ForwardingFailedError(*args, **kwargs)[source]¶ Bases:
requests_proxy_adapter.exceptions.PrivoxyError4RetryPrivoxy error response contains forwarding-failed message.
-
exception
requests_proxy_adapter.exceptions.NoServerDataError(*args, **kwargs)[source]¶ Bases:
requests_proxy_adapter.exceptions.PrivoxyError4RetryPrivoxy error response contains no-server-data message.
-
exception
requests_proxy_adapter.exceptions.PrivoxyError(*args, **kwargs)[source]¶ Bases:
requests.exceptions.ProxyErrorBase class for Privoxy-related exceptions.
-
exception
requests_proxy_adapter.exceptions.PrivoxyError4Retry(*args, **kwargs)[source]¶ Bases:
requests_proxy_adapter.exceptions.PrivoxyErrorBase class for cases needed retrying request internally.