Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make order of headers repeatable #474

Merged
merged 2 commits into from Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -23,6 +23,7 @@
* Some micro-optimizations for request matching

**Bugfixes:**
* Fix regression bug causing headers used for cache key to not guarantee sort order
* Handle some additional corner cases when normalizing request data
* Add support for `BaseCache` keyword arguments passed along with a backend instance
* Fix issue with cache headers not being used correctly if `cache_control=True` is used with an `expire_after` value
Expand Down
4 changes: 3 additions & 1 deletion requests_cache/cache_keys.py
Expand Up @@ -81,7 +81,9 @@ def get_matched_headers(
else:
included = set(headers) - DEFAULT_EXCLUDE_HEADERS

return [f'{k.lower()}={headers[k]}' for k in included if k in headers]
return [
f'{k.lower()}={headers[k]}' for k in sorted(included, key=lambda x: x.lower()) if k in headers
]


def normalize_request(request: AnyRequest, ignored_parameters: ParamList) -> AnyPreparedRequest:
Expand Down