Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 503d965

Browse files
authored
Fix parsing of Accept header.
JSONAPI 1.0 specification says: “Clients that include the JSON API media type in their Accept header MUST specify the media type there at least once without any media type parameters.” That means, that there may be other acceptable MIME types, which the string comparison that was in place before prevented. This should also help with issue #13.
1 parent 426da16 commit 503d965

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flask_rest_jsonapi/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def wrapper(*args, **kwargs):
2323
'title': 'InvalidRequestHeader',
2424
'status': 415}]))
2525
return make_response(error, 415, {'Content-Type': 'application/vnd.api+json'})
26-
if request.headers.get('Accept') and request.headers['Accept'] != 'application/vnd.api+json':
26+
if request.headers.get('Accept') and not 'application/vnd.api+json' in request.accept_mimetypes:
2727
error = json.dumps(jsonapi_errors([{'source': '',
2828
'detail': "Accept header must be application/vnd.api+json",
2929
'title': 'InvalidRequestHeader',

0 commit comments

Comments
 (0)