Repository navigation
fix(transport): match explicit HTTP media types and Accept quality values #1382
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
Open
passionworkeer
wants to merge
2
commits into
modelcontextprotocol:main
Choose a base branch
from
passionworkeer:fix/http-media-type-matching
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+295
−15
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table covers the zero and positive boundary, but not the upper bound or malformed weights. So the
"1"case and rejection paths inquality_is_acceptableare still untested. Could we add tests for those too, based on whatever behavior we settle on for malformed weights?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed—the current matrix misses the
1branch and malformed-weight rejection. I’ll add the upper-bound and malformed cases here, including1,1.,1.000, over-precision, values above one, missing leading zero, and negative weights. Malformed weights will be tested against this implementation’s admission policy, without claiming full HTTP negotiation.Thanks also to theamodhshetty for the supplemental matrix and independent macOS run. That covers this gap well; it has not been folded into the branch yet, and I’ll rerun the tests on the resulting commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in e0eb843.
The matrix now covers the upper bound and the rejection paths in
quality_is_acceptable. Accepted:q=1,q=1.,q=1.000, andtext/event-stream;q=0.01. Rejected with 406:q=0.0001(more than three fractional digits),q=1.001(a fraction on a weight of one),q=.5(no whole part),q=-0.1(negative),q=abc(not a number), andtext/event-stream;q=0(zero weight on a required type).To be explicit about the behaviour you asked to settle on: a qvalue that is not
0or1with at most three fractional digits is treated as not acceptable, rather than being coerced to 0 or 1. That is this implementation's existing admission policy, not a claim about how a general HTTP stack should negotiate.The GET-side cases got the same treatment:
text/event-stream;q=1,q=1.andq=1.000still reach the legacy session check (400), whileq=1.001,q=0.0001,q=.5,q=-0.1andq=abcare rejected (406).Validation on this revision: all 67 tests across the six HTTP integration targets and 378 library tests passed, plus targeted Clippy with warnings denied and nightly formatting. Those are local checks; the upstream workflows on this head are waiting on maintainer approval.