diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2021-09-20 19:25:57 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2021-09-20 23:33:30 -0500 |
commit | ec3b35011b611a2af438842093e6365ea5218343 (patch) | |
tree | a4cf334fa76c7532cd1e92b9c08ec273aff53a09 | |
parent | e8c6736f0cea69fab4fc80f09b96a55c5ee68826 (diff) | |
download | requests-cache-ec3b35011b611a2af438842093e6365ea5218343.tar.gz |
Update changelog and some docstrings
-rw-r--r-- | HISTORY.md | 2 | ||||
-rw-r--r-- | requests_cache/session.py | 18 |
2 files changed, 14 insertions, 6 deletions
@@ -4,6 +4,8 @@ * Use `Cache-Control` **request** headers by default * Support `expire_after` param for `CachedSession.send()` * Make per-request expiration thread-safe for both `CachedSession.request()` and `CachedSession.send()` +* Handle some additional corner cases when normalizing request data +* Some micro-optimizations for request matching ## 0.8.1 (2021-09-15) * Redact `ingored_parameters` from `CachedResponse.url` (if used for credentials or other sensitive info) diff --git a/requests_cache/session.py b/requests_cache/session.py index bc6ffd5..a2234be 100644 --- a/requests_cache/session.py +++ b/requests_cache/session.py @@ -129,8 +129,13 @@ class CacheMixin(MIXIN_BASE): def send( self, request: PreparedRequest, expire_after: ExpirationTime = None, **kwargs ) -> AnyResponse: - """Send a prepared request, with caching. See :py:meth:`.request` for notes on behavior.""" - # Determine which actions to take based on request info, headers, and cache settings + """Send a prepared request, with caching. See :py:meth:`.request` for notes on behavior, and + see :py:meth:`requests.Session.send` for parameters. Additional parameters: + + Args: + expire_after: Expiration time to set only for this request + """ + # Determine which actions to take based on request info and cache settings cache_key = self.cache.create_key(request, **kwargs) actions = CacheActions.from_request( cache_key=cache_key, @@ -149,7 +154,7 @@ class CacheMixin(MIXIN_BASE): actions.update_from_cached_response(cached_response) is_expired = getattr(cached_response, 'is_expired', False) - # If the response is expired, missing, or the cache is disabled, then fetch a new response + # If the response is expired or missing, or the cache is disabled, then fetch a new response if cached_response is None: response = self._send_and_cache(request, actions, **kwargs) elif is_expired and self.stale_if_error: @@ -159,7 +164,7 @@ class CacheMixin(MIXIN_BASE): else: response = cached_response - # If the request has been filtered out, delete the previously cached response if it exists + # If the request has been filtered out and was previously cached, delete it if not self.filter_fn(response): logger.debug(f'Deleting filtered response for URL: {response.url}') self.cache.delete(cache_key) @@ -310,8 +315,9 @@ class CachedSession(CacheMixin, OriginalSession): @contextmanager def patch_form_boundary(**request_kwargs): - """Patch the form boundary used to separate multipart uploads. ``requests`` does not provide a - way to pass a custom boundary to urllib3, so this just monkey-patches it instead. + """If the ``files`` param is present, patch the form boundary used to separate multipart + uploads. ``requests`` does not provide a way to pass a custom boundary to urllib3, so this just + monkey-patches it instead. """ if request_kwargs.get('files'): original_boundary = filepost.choose_boundary |