Skip to content

fix: only response with html if client prefers media type#1271

Merged
josevalim merged 3 commits intoelixir-plug:mainfrom
xanderio:push-pnnxqsqqnoqt
May 30, 2025
Merged

fix: only response with html if client prefers media type#1271
josevalim merged 3 commits intoelixir-plug:mainfrom
xanderio:push-pnnxqsqqnoqt

Conversation

@xanderio
Copy link
Copy Markdown
Contributor

The previous implemtantion has quite basic and didn't account for the q parameter a client can add to an entry in the accept header.

This would fail with HTTPie, which send requests with "Accept: application/json, text/*;q=0.5". While one can argument that responding with HTML is in spec, it isn't a good DX.

The previous implemtantion has quite basic and didn't account for the q
parameter a client can add to an entry in the accept header. 

This would fail with HTTPie, which send requests with 
"Accept: application/json, text/*;q=0.5". While one can argument that
responding with HTML is in spec, it isn't a good DX.
Comment thread lib/plug/debugger.ex Outdated
Comment thread lib/plug/debugger.ex Outdated
@josevalim josevalim merged commit 57d04d7 into elixir-plug:main May 30, 2025
2 checks passed
@josevalim
Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@xanderio xanderio deleted the push-pnnxqsqqnoqt branch May 31, 2025 04:39
josevalim added a commit that referenced this pull request Jul 1, 2025
This was causing markdown to be rendered in at least Safari.

This reverts commit 57d04d7.
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