Skip to content

Loosen accept header check#185

Closed
ngseer wants to merge 2 commits intovovanbo:masterfrom
ngseer:loosen-accept-header-check
Closed

Loosen accept header check#185
ngseer wants to merge 2 commits intovovanbo:masterfrom
ngseer:loosen-accept-header-check

Conversation

@ngseer
Copy link
Copy Markdown

@ngseer ngseer commented Mar 2, 2018

Allow to sent requests with Accept header that contains more than one media types as long as it contains application/vnd.api+json or */* media type.

Also allow to use */* media type with parameters which is required for proper OPTIONS requests handling is some cases.

For example, Firefox generates text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept header for that kind of requests.

@vovanbo
Copy link
Copy Markdown
Owner

vovanbo commented Mar 2, 2018

@DmitryNikonov JSON API specification describe a content negotiation more strict than you expect. Look at Content Negotiation.

Clients MUST send all JSON API data in request documents with the header Content-Type: application/vnd.api+json without any media type parameters.

Servers MUST respond with a 406 Not Acceptable status code if a request’s Accept header contains the JSON API media type and all instances of that media type are modified with media type parameters.

Anyway, look at python-mimeparse. There is a best_match method here.

@ngseer
Copy link
Copy Markdown
Author

ngseer commented Mar 2, 2018

@vovanbo

Clients MUST send all JSON API data in request documents with the header Content-Type: application/vnd.api+json without any media type parameters.

PR changes don't affect Content-Type header.

Servers MUST respond with a 406 Not Acceptable status code if a request’s Accept header contains the JSON API media type and all instances of that media type are modified with media type parameters.

To be clear, I'm still not sure if there's a contradiction with what I wrote in the oppost. Specs say that server MUST reject a request with Accept header that contains JSON API media type but doesn't contain JSON API media type without parameters. So it doesn't seem to affect requests that don't contain JSON API media type in Accept header.

You may also look at that discussion on the same topic.

@vovanbo vovanbo closed this in 7074e08 Mar 2, 2018
@vovanbo
Copy link
Copy Markdown
Owner

vovanbo commented Mar 2, 2018

@DmitryNikonov Fixed in 0.36.0. Thank you!

@vovanbo
Copy link
Copy Markdown
Owner

vovanbo commented Mar 2, 2018

@DmitryNikonov Build was failed, but I'll fix it soon.

@ngseer
Copy link
Copy Markdown
Author

ngseer commented Mar 3, 2018

Thank you very much!

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.

2 participants