Skip to content

Fix case-insensitive stable sorting of response headers - #1961

Open
xu91102 wants to merge 1 commit into
httpie:masterfrom
xu91102:fix/header-sort-case-insensitive
Open

xu91102 wants to merge 1 commit into
httpie:masterfrom
xu91102:fix/header-sort-case-insensitive

Conversation

@xu91102

@xu91102 xu91102 commented Sep 26, 2026 •

Copy link
Copy Markdown

Use a lowercase field-name sort key when formatting headers. Previously repeated fields with different capitalization could be reordered, despite the formatter's order-preservation contract.

Python's stable sort now groups case-insensitively equal names while preserving their original order, spelling and values. The status line is unchanged. A regression includes differently capitalized Set-Cookie fields and neighboring fields; it fails before the fix.

Validation: all 122 output tests pass (3 expected failures), plus Flake8 and diff checks. Tests ran with proxy environment variables removed so the invalid-host test exercises its intended network error. Prepared with Codex assistance.

Fixes #1960

Remote CI baseline note: two Big5 charset-detection tests fail in an untouched checkout of base 5b604c3; this change does not modify charset detection.

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.

Header formatting reorders repeated fields with mixed capitalization

1 participant