generated from apollographql/typescript-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 23
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
JSON body is not parsed when Content-Type contains a charset #341
Comments
See #229. |
slagiewka
added a commit
to slagiewka/datasource-rest
that referenced
this issue
Dec 22, 2024
Or other parameters. In accordance with RFC 1341[^1], Content-Type contains first and foremost the media type. It can be followed by key-value pairs of parameters. This change supports extracting the media type and effectively discarding the other parameters as these are currently irrelevant to body parsing. The result media type is then matched against previously used JSON type tests. Closes apollographql#229 Closes apollographql#341 [^1]:https://www.rfc-editor.org/rfc/rfc1341
slagiewka
added a commit
to slagiewka/datasource-rest
that referenced
this issue
Dec 22, 2024
Or other parameters. In accordance with RFC 1341[^1], Content-Type contains first and foremost the media type. It can be followed by key-value pairs of parameters. This change supports extracting the media type and effectively discarding the other parameters as these are currently irrelevant to body parsing. The result media type is then matched against previously used JSON type tests. Closes apollographql#229 Closes apollographql#341 [^1]:https://www.rfc-editor.org/rfc/rfc1341
slagiewka
added a commit
to slagiewka/datasource-rest
that referenced
this issue
Dec 22, 2024
Or other parameters. In accordance with RFC 1341[^1], Content-Type contains first and foremost the media type. It can be followed by key-value pairs of parameters. This change supports extracting the media type and effectively discarding the other parameters as these are currently irrelevant to body parsing. The result media type is then matched against previously used JSON type tests. Closes apollographql#229 Closes apollographql#341 [^1]:https://www.rfc-editor.org/rfc/rfc1341
slagiewka
added a commit
to slagiewka/datasource-rest
that referenced
this issue
Dec 22, 2024
Or other parameters. In accordance with RFC 9110[^1], Content-Type contains first and foremost the media type. It can be followed by key-value pairs of parameters. This change supports extracting the media type and effectively discarding the other parameters as these are currently irrelevant to body parsing. The result media type is then matched against previously used JSON type tests. Closes apollographql#229 Closes apollographql#341 [^1]:https://www.rfc-editor.org/rfc/rfc9110.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My back-end returns JSON data with a content-header that contains the suffix
+json
'and thecharset=utf-8'
The content-type is not recognized as JSON and the body is returned as a plain string instead of JSON.
The problem is the way that the
Content-Type
header is parsed:Content-Type: application/whatever+json;charset=utf-8
This is the method for parsing the header (and the body):
The condition for checking on JSON fails, because:
contentType.endsWith('+json')
is
false
in the case that there is a charset defined at the end of the headerThe text was updated successfully, but these errors were encountered: