Skip to content

Remove charset from JSON mime type as it is invalid per RFC 7159#1881

Merged
ysangkok merged 2 commits into
masterfrom
incorrect-mime-type-for-json
May 8, 2026
Merged

Remove charset from JSON mime type as it is invalid per RFC 7159#1881
ysangkok merged 2 commits into
masterfrom
incorrect-mime-type-for-json

Conversation

@tchoutri

@tchoutri tchoutri commented May 5, 2026

Copy link
Copy Markdown
Contributor

See
https://stackoverflow.com/questions/4990095/json-specification-and-usage-of-bom-charset-encoding

Closes #1715 #559 #849

This will enable us to query Hackage, which is overly restrictive and has not changed its behaviour since 2019 haskell/hackage-server#839.

Hackage itself is not wrong, just annoying. RFC 7159 was amended in its favour: https://www.rfc-editor.org/errata/eid5853

cc @ysangkok @alt-romes

@tchoutri tchoutri requested a review from ysangkok May 5, 2026 13:19
@tchoutri tchoutri marked this pull request as draft May 5, 2026 13:19
@tchoutri tchoutri force-pushed the incorrect-mime-type-for-json branch from 6d341c3 to ac239c1 Compare May 5, 2026 13:23
@ysangkok

ysangkok commented May 5, 2026

Copy link
Copy Markdown
Contributor

why is it a draft?

@tchoutri

tchoutri commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@ysangkok I wanted to ensure CI was passing as expected before submitting for review but I already assigned you so it doesn't really make sense indeed.

@tchoutri tchoutri marked this pull request as ready for review May 5, 2026 13:29
@ysangkok

ysangkok commented May 8, 2026

Copy link
Copy Markdown
Contributor

tests still fail:

  1) Servant.API.ContentTypes.Servant.API.ContentTypes.handleAcceptH respects the Accept spec ordering
       Falsified (after 7 tests and 1 shrink):
         ZeroToOne 0.3
         ZeroToOne 0.4
         ZeroToOne 0.8
         0
         AcceptHeader "text/plain;charset=utf-8; q=0.8, application/json; q=0.4, application/octet-stream; q=0.3"
         "text/plain;charset=utf-8" /= "text/plain"

@tchoutri tchoutri force-pushed the incorrect-mime-type-for-json branch from 63dea31 to 786e29b Compare May 8, 2026 16:55
@tchoutri tchoutri force-pushed the incorrect-mime-type-for-json branch 4 times, most recently from f84ad9b to af624dd Compare May 8, 2026 16:59
@tchoutri tchoutri force-pushed the incorrect-mime-type-for-json branch from af624dd to 60d26ad Compare May 8, 2026 17:59
@ysangkok ysangkok merged commit 6a594bc into master May 8, 2026
11 checks passed
@ysangkok ysangkok deleted the incorrect-mime-type-for-json branch May 8, 2026 19:06
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.

Get '[JSON] does not imply a header Accept: application/json

2 participants