mirror of
https://github.com/sprockets/sprockets.mixins.http.git
synced 2024-11-14 19:29:31 +00:00
Merge pull request #9 from nvllsvm/additional_kwargs
Expose additional fetch parameters
This commit is contained in:
commit
62c9c843c6
1 changed files with 9 additions and 0 deletions
|
@ -55,6 +55,7 @@ class HTTPClientMixin(object):
|
|||
DEFAULT_REQUEST_TIMEOUT = 60
|
||||
|
||||
MAX_HTTP_RETRIES = 3
|
||||
MAX_REDIRECTS = 5
|
||||
|
||||
@gen.coroutine
|
||||
def http_fetch(self, url,
|
||||
|
@ -63,12 +64,14 @@ class HTTPClientMixin(object):
|
|||
body=None,
|
||||
content_type=CONTENT_TYPE_MSGPACK,
|
||||
follow_redirects=False,
|
||||
max_redirects=MAX_REDIRECTS,
|
||||
connect_timeout=DEFAULT_CONNECT_TIMEOUT,
|
||||
request_timeout=DEFAULT_REQUEST_TIMEOUT,
|
||||
max_http_attempts=MAX_HTTP_RETRIES,
|
||||
auth_username=None,
|
||||
auth_password=None,
|
||||
user_agent=None,
|
||||
validate_cert=True,
|
||||
allow_nonstandard_methods=False):
|
||||
"""Perform a HTTP request
|
||||
|
||||
|
@ -83,6 +86,8 @@ class HTTPClientMixin(object):
|
|||
:type content_type: :class:`~ietfparse.datastructures.ContentType` or
|
||||
str
|
||||
:param bool follow_redirects: Follow HTTP redirects when received
|
||||
:param int max_redirects: Maximum number of redirects to follow,
|
||||
default is 5
|
||||
:param float connect_timeout: Timeout for initial connection in
|
||||
seconds, default 20 seconds
|
||||
:param float request_timeout: Timeout for entire request in seconds,
|
||||
|
@ -93,6 +98,8 @@ class HTTPClientMixin(object):
|
|||
:param str auth_password: Password for HTTP authentication
|
||||
:param str user_agent: The str used for the ``User-Agent`` header,
|
||||
default used if unspecified.
|
||||
:param bool validate_cert: For HTTPS requests, validate the server's
|
||||
certifacte? Default is True
|
||||
:param bool allow_nonstandard_methods: Allow methods that don't adhere
|
||||
to the HTTP spec.
|
||||
:rtype: HTTPResponse
|
||||
|
@ -127,7 +134,9 @@ class HTTPClientMixin(object):
|
|||
request_timeout=request_timeout,
|
||||
user_agent=user_agent or self._http_req_user_agent(),
|
||||
follow_redirects=follow_redirects,
|
||||
max_redirects=max_redirects,
|
||||
raise_error=False,
|
||||
validate_cert=validate_cert,
|
||||
allow_nonstandard_methods=allow_nonstandard_methods)
|
||||
except (OSError, socket.gaierror) as error:
|
||||
LOGGER.debug('HTTP Request Error for %s to %s'
|
||||
|
|
Loading…
Reference in a new issue