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

Refine Content-Type negotiation #229

Open
trevor-scheer opened this issue Jul 10, 2023 · 0 comments · May be fixed by #391
Open

Refine Content-Type negotiation #229

trevor-scheer opened this issue Jul 10, 2023 · 0 comments · May be fixed by #391

Comments

@trevor-scheer
Copy link
Member

The parseBody function is only using startsWith and endsWith to figure the content type.

(contentType.startsWith('application/json') ||
contentType.endsWith('+json'))

In most cases (application/json) this is fine. But for users depending on the +json condition, this breaks for cases like this one:

application/ld+json; charset=utf-8

Ref: #228 (reply in thread)

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 slagiewka linked a pull request Dec 22, 2024 that will close this issue
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant