mirror of
https://github.com/sprockets/sprockets.mixins.http.git
synced 2024-11-14 19:29:31 +00:00
Pass kwargs through to http client fetch.
This commit is contained in:
parent
7058cb3f27
commit
7309cff4cc
3 changed files with 24 additions and 2 deletions
|
@ -1,6 +1,11 @@
|
|||
Version History
|
||||
===============
|
||||
|
||||
Next Release
|
||||
------------
|
||||
- Pass keyword parameters through to the underlying HTTPClient fetch method.
|
||||
This enables niceties like streaming callback support
|
||||
|
||||
`2.3.1`_ Apr 7, 2020
|
||||
--------------------
|
||||
- Address `#27`_ by using the shortest appropriate timeout
|
||||
|
|
|
@ -272,7 +272,8 @@ class HTTPClientMixin:
|
|||
user_agent=None,
|
||||
validate_cert=True,
|
||||
allow_nonstandard_methods=False,
|
||||
dont_retry=None):
|
||||
dont_retry=None,
|
||||
**kwargs):
|
||||
"""Perform a HTTP request
|
||||
|
||||
Will retry up to ``self.MAX_HTTP_RETRIES`` times.
|
||||
|
@ -304,6 +305,8 @@ class HTTPClientMixin:
|
|||
to the HTTP spec.
|
||||
:param set dont_retry: A list of status codes that will not be retried
|
||||
if an error is returned. Default: set({})
|
||||
:param kwargs: additional keyword parameters are passed to
|
||||
:meth:`tornado.httpclient.AsyncHTTPClient.fetch`
|
||||
:rtype: HTTPResponse
|
||||
|
||||
"""
|
||||
|
@ -353,7 +356,8 @@ class HTTPClientMixin:
|
|||
max_redirects=max_redirects,
|
||||
raise_error=False,
|
||||
validate_cert=validate_cert,
|
||||
allow_nonstandard_methods=allow_nonstandard_methods)
|
||||
allow_nonstandard_methods=allow_nonstandard_methods,
|
||||
**kwargs)
|
||||
except (OSError, httpclient.HTTPError) as error:
|
||||
response.append_exception(error)
|
||||
LOGGER.warning(
|
||||
|
|
13
tests.py
13
tests.py
|
@ -615,3 +615,16 @@ class MixinTestCase(testing.AsyncHTTPTestCase):
|
|||
self.assertAlmostEqual(response.duration,
|
||||
response.attempts * 0.25,
|
||||
places=1)
|
||||
|
||||
@testing.gen_test
|
||||
def test_that_kwargs_are_passed_through(self):
|
||||
chunks = []
|
||||
|
||||
def streaming_callback(chunk):
|
||||
chunks.append(chunk)
|
||||
|
||||
response = yield self.mixin.http_fetch(
|
||||
self.get_url('/test'),
|
||||
streaming_callback=streaming_callback)
|
||||
self.assertTrue(response.ok)
|
||||
self.assertGreater(len(chunks), 0)
|
||||
|
|
Loading…
Reference in a new issue