Repository navigation
Require tiny-blocks/http 8.0 and reject malformed mapped headers. - #12
Merged
Merged
Conversation
tiny-blocks/http 8.0 refuses Connection, Keep-Alive, Proxy-Connection, Transfer-Encoding, Upgrade and a TE other than trailers on a response, so a rule declaring one would have made the error response itself throw inside the middleware. MappedError now refuses it with HttpHeaderMalformed, as HTTP/2 and HTTP/3 treat such a response as malformed.
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.
Summary
MappedErrorrejects a header whose name or value ends in a line feed withHttpHeaderMalformed. TheNAMEandVALUEpatterns ofResponseHeadersended in$without theDmodifier, and$matches before a final\n, so"Retry-After\n"and"60\n"passed.D, and two tests cover the trailing line feed on the name and on the value.composer.jsonrequirestiny-blocks/http^8.0(was^7.2). 8.0 validates every header that reaches a response and rejects the connection-specific ones (tiny-blocks/http#74).MappedErroralso rejects a connection-specific header (Connection,Keep-Alive,Proxy-Connection,Transfer-Encoding,Upgrade, andTEwith any value other thantrailers, names case-insensitive) withHttpHeaderMalformed. Under 8.0 a rule declaring one would have madewithHeader()throwHeaderIsConnectionSpecificwhile the error response was being built, inside the middleware. HTTP/2 and HTTP/3 treat such a response as malformed, so the existing exception fits. The README and theHttpHeaderMalformeddocblock document it.CI
CI resolves
tiny-blocks/http^8.0from Packagist, so it stays red untiltiny-blocks/http8.0.0is published. Merge after that release and a green re-run. Locally,make reviewandmake testspass against the 8.0 branch oftiny-blocks/httpinstalled through a temporary, uncommitted path repository (143 tests, 214 mutants, MSI 100%).Release
Recommended release:
3.0.0(major), replacing the2.0.5this PR first proposed. The public API exposestiny-blocks/httptypes (TinyBlocks\Http\CodeinErrorPayload,ReportedError,ReportingPriorityandErrorMiddlewareBuilder), so raising the required major of that dependency is a breaking change for consumers. Rejecting connection-specific mapped headers is also input that used to pass and now throws.Related issue
None.
Checklist
make reviewpasses.make testspasses.