Repository navigation
Conversation
Motivation: apache#1471 accepted empty parameter slots in Content-Type by copying the media-type grammar, so the shared rule, which the Link header's `type` parameter uses, stayed strict. apache#1470 made Encoder and Decoder recognise a raw Content-Encoding header, but HttpMessage.encoding (and so requestEncodedWith and decodeRequestWith) still only saw the modeled header. Modification: - Allow empty parameter slots in the shared `media-type` rule and use it for Content-Type again, so Link's `type` parameter accepts them too. - Drop the http-model.md paragraph about empty slots, which describes standard parser behaviour users can't configure. - HttpMessage.encoding reads a raw Content-Encoding header when there is no modeled one. A value that doesn't parse is reported as a custom encoding, not identity, so the encoded entity can't pass as unencoded. Result: Content-Type and Link share one media-type grammar, and a raw Content-Encoding header is treated the same by Encoder, Decoder and HttpMessage.encoding. Tests: - http-core/testOnly HttpHeaderSpec HeaderSpec HttpMessageSpec HttpHeaderParserCRLFSpec HttpHeaderParserLFSpec: 210 passed - http-tests/testOnly CodingDirectivesSpec CodersSpec: 86 passed - http-core/mimaReportBinaryIssues, http/mimaReportBinaryIssues: passed References: Refs apache#1470, apache#1471
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation:
A couple of loose ends from #1470 and #1471, found when re-reading them after merge.
Modification:
ContentTypeHeader. The sharedmedia-typerule inCommonRulesstayed strict, and thetypeparameter ofLinkuses it, soLink: </>; type="application/json;;foo=bar;"was still rejected. The #1471 review asked aboutLink. The empty-slot handling now lives in the shared rule, andContent-Typeuses that rule again, so there's one copy of the grammar.http-model.mdparagraph describes RFC-allowed parser tolerance that users can't configure, the kind of paragraph dropped on other recent PRs (e.g. fix: preserve characters after unpaired URI surrogates #1426, fix: accept zero-offset Cookie Expires dates #1493).HttpMessage.encodingsees a rawContent-Encoding(Preserve explicit Content-Encoding during automatic encoding #1470): Preserve explicit Content-Encoding during automatic encoding #1470 madeEncoderandDecoderrecognise aContent-Encodingheader by name (#1470 review). ButHttpMessage.encoding, whichrequestEncodedWithand sodecodeRequestWithuse, still only read the modeled header. A request carrying a rawContent-Encoding: gzipreportedidentity, anddecodeRequestWith(Gzip)rejected it.encodingnow reads a raw header when there's no modeled one. A value that doesn't parse is reported as a custom encoding rather thanidentity, so a still-encoded entity can't pass as unencoded throughNoCoding.Result:
Content-TypeandLinkshare one media-type grammar, andEncoder,DecoderandHttpMessage.encodingtreat a rawContent-Encodingheader the same way. The parser always produces the modeledContent-Encoding, so theencodingchange only matters for messages built by hand.Tests:
http-core/testOnly HttpHeaderSpec HeaderSpec HttpMessageSpec HttpHeaderParserCRLFSpec HttpHeaderParserLFSpec: 210 passed. New:Linkwith empty slots intype, andHttpMessage.encodingwith no, modeled, raw and unparseable raw headers.http-tests/testOnly CodingDirectivesSpec CodersSpec: 86 passed. New:decodeRequestWith(Gzip)decodes a request with a rawContent-Encoding: gzip.http-core/mimaReportBinaryIssues,http/mimaReportBinaryIssues: passedReferences:
Refs #1470, #1471. The related
Decoder.decodeMessageissue (decoding regardless of the header value) is #1507.🤖 Generated with Claude Code