Skip to content

Fix content negotiation (q-values, Vary: Accept) - #8

Merged
retlehs merged 1 commit into
mainfrom
vary-accept-and-q-value-handling
Apr 18, 2026
Merged

retlehs merged 1 commit into
mainfrom
vary-accept-and-q-value-handling

Conversation

@retlehs

@retlehs retlehs commented Apr 18, 2026

Copy link
Copy Markdown
Member

isMarkdownRequested() previously did a substring match on the Accept header, which incorrectly returned true for clients that listed text/markdown but preferred text/html (e.g. Accept: text/html, text/markdown;q=0.5). It now parses per RFC 9110, picking the most specific matching entry and only returning true when markdown's q-value strictly exceeds html's.

Also emits Vary: Accept on every front-end response (not just the markdown ones) so downstream caches can't cross-serve an HTML response to a later Markdown request for the same URL. Can be disabled via the post_content_to_markdown/emit_vary filter; Markdown responses keep their own explicit Vary regardless.

@retlehs retlehs self-assigned this Apr 18, 2026
@retlehs
retlehs merged commit ccabee1 into main Apr 18, 2026
1 check passed
@retlehs
retlehs deleted the vary-accept-and-q-value-handling branch April 18, 2026 16:16
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.

1 participant