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

fix(gateway): JSON when Accept is a list #9533

Merged
merged 1 commit into from Jan 11, 2023
Merged

Conversation

lidel
Copy link
Member

@lidel lidel commented Jan 11, 2023

This PR fixes #9520 by adding basic support for Accept headers with a list of content types (pick the first matching one).

cc @hacdias if you have time to eyeball – would like to include this in 0.18.

Context

Block/CAR responses introduced in #8758 always had single explicit type, and we did not bother with implementing/testing lists.

With the introduction of JSON added in #9335 (Kubo 0.18) people started passing a list, as noted in #9520.

Note: this PR does not implement weights because afaik golang still does not include this in standard library, and I wanted to avoid adding dependency like https://github.com/aohorodnyk/mimeheader. Returning the first match should be good enough for now, as we don't have a use case where the user would like to mix CAR and JSON.

Closes #9520

Block/CAR responses always had single explicit type, and we did not bother
with implementing/testing lists.

With the introduction of JSON people may start passing a list.
This is the most basic fix which will return on the first matching
type (in order). This does not implements weights (can be added in
future, if needed).

Closes #9520
@hacdias
Copy link
Member

hacdias commented Jan 11, 2023

Thanks for this, it makes sense to be fixed.

@lidel lidel merged commit f6825ab into master Jan 11, 2023
@lidel lidel deleted the fix/accept-header-parsing branch January 11, 2023 21:18
@lidel lidel mentioned this pull request Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.18.0-rc2: 400 when "Accept: application/json, text/plain"
2 participants