Skip to content

xh lowercases all headers #166

@CosmicToast

Description

@CosmicToast

What I expect

Xh copies case of user-specified headers.

What actually happens

Xh treats all headers as case-insensitive and lowercases them.

Why is this a problem?

  1. It's a difference from httpie.
  2. It has a negative net effect when interacting with non-compliant servers.

To explain 2...

Some services treat headers as case-sensitive (e.g with X-* headers, especially for auth).
The HTTP specification does specify that headers are case-insensitive, however, consider the following matrix.
If headers are treated as case insensitive, this will break servers that (incorrectly) treat them as case-sensitive, while not having a negative effect on compliant servers.
If headers are treated as case sensitive, this will work with the non-compliant servers, while not having a negative effect on compliant servers.

It would also be ok to auto-capitalize headers (e.g foO-baR-baZ could become Foo-Bar-Baz), since that's what standard industry practice anyway, but this is not what HTTPie does.

How to test compliance

xh --print=H localhost My-OdDlY-Capitalized-Header:Here
compare to
http --print=H localhost My-OdDlY-Capitalized-Header:Here

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions