Header formatting reorders repeated fields with mixed capitalization
Author: xu91102Created Sep 26, 2026Updated Sep 26, 2026
The header formatter promises to preserve the relative order of repeated fields, but sorting is case-sensitive. Given:
HTTP/1.1 200 OK
set-cookie: first=1
X-Z: last
Set-Cookie: second=2
accept: text/plainthe formatter moves Set-Cookie: second=2 before set-cookie: first=1. HTTP field names are case-insensitive, so these are repeated fields and their display order should remain unchanged. Case-sensitive sorting also places X-Z before accept.
Expected accept first, then both cookie lines in original order, then X-Z, preserving original spelling and values. Reproduced on master with Python 3.12.13, macOS. Prepared with Codex assistance.
Source: httpie/cli