Repository navigation
FIX: Keep every Cookie line in HTTPTarget raw requests - #3691
Open
ni (nniiovoo) wants to merge 1 commit into
Open
ni (nniiovoo) wants to merge 1 commit into
ni (nniiovoo) wants to merge 1 commit into
Conversation
parse_raw_http_request stored headers in a dict keyed by name, so a repeated Cookie line overwrote the earlier ones. A raw request with its cookies split across lines lost all but the last cookie, with no error. Join repeated Cookie lines with "; " (RFC 9113 8.2.3), skipping empty ones. Other headers keep their last value as before, and raw headers still replace client defaults. Signed-off-by: NNIIOVO <haimingni44@gmail.com>
This branch has not been deployed
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.
Description
parse_raw_http_requestkept only the last line of a repeated header, so a raw request with its cookies split across lines lost all but the last cookie.This joins repeated
Cookielines with;(RFC 9113 8.2.3) and skips empty ones. TwoCookielines with the same name now both go out, where main sent only the last. Other repeated headers keep their last value, same as today. I didn't comma-join them because that breaks single-value headers: a local FastAPI app returned 422 for a joinedContent-Typeand rejected a joinedAuthorizationtoken. Repeated list headers likeX-Forwarded-Forstill lose their earlier lines, which I can handle separately if you want.Fixes #3690
Tests and Documentation
Added parse tests for the joined cookies and empty
Cookielines and a send test for the joined cookies, which fail on main and pass with the fix. Two more tests pin what shouldn't change: last-wins for other headers, and a rawCookiereplacing a client default. The prompt_target unit tests, ruff andty checkon the changed source file pass, and so does pre-commit without the ty hook. No doc changes.