Skip to content

FIX: Keep every Cookie line in HTTPTarget raw requests - #3691

Open
ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:fix/http-target-repeated-headers
Open

ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:fix/http-target-repeated-headers

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Description

parse_raw_http_request kept 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 Cookie lines with ; (RFC 9113 8.2.3) and skips empty ones. Two Cookie lines 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 joined Content-Type and rejected a joined Authorization token. Repeated list headers like X-Forwarded-For still 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 Cookie lines 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 raw Cookie replacing a client default. The prompt_target unit tests, ruff and ty check on the changed source file pass, and so does pre-commit without the ty hook. No doc changes.

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

No deployments
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.

BUG: HTTPTarget drops all but the last Cookie line in a raw request

1 participant