accept-encoding.acceptable_offers is not very useful for the common use case
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by locating the implementations of acceptable_offers and the deprecated best_match API in the WebOb source, then inspect their tests. Compare behavior for a missing Accept-Encoding header with the examples in this issue; done means the proposed API handles the default identity encoding and preserves offer ordering without the old quality multiplier logic.
Written by the indexing model from the issue text.
Description
While this api is compliant with the RFC at https://tools.ietf.org/html/rfc7231#section-5.3.4, it is not what anybody really expects or wants in the case of a missing header. The answer is pretty much always to use identity when a header is missing. This is what the deprecated best_match api used to do, with best_match(['identity', 'gzip'], default_match='identity').
>>> create_accept_encoding_header(None).acceptable_offers(['identity', 'gzip'])
[('identity', 1.0), ('gzip', 1.0)]
>>> create_accept_encoding_header(None).best_match(['identity', 'gzip'], default_match='identity')
'identity'
The proposed api would be something that implements the following:
offers = ['gzip', 'identity'] # order matters here
default_encoding = 'identity'
if request.accept_encoding:
encodings = request.accept_encoding.acceptable_offers(offers)
target_encoding = encodings[0][0] if encodings else default_encoding
else:
target_encoding = default_encoding
This is very similar to best_match but without any weird server-side quality multiplier logic.
- Dominant language
- Python
- Stars
- 443
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Pylons/webob
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Adding type hints Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100