Skip to content

Header formatting reorders repeated fields with mixed capitalization #1960

Description

@xu91102

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/plain

the 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions