Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to preserve header's title case #2313

Closed
zonyitoo opened this issue Oct 27, 2020 · 4 comments
Closed

Option to preserve header's title case #2313

zonyitoo opened this issue Oct 27, 2020 · 4 comments
Labels
A-http1 Area: HTTP/1 specific. S-feature Severity: feature. This is adding a new feature.

Comments

@zonyitoo
Copy link
Contributor

zonyitoo commented Oct 27, 2020

I am building a HTTP proxy with hyper, and I realize that headers are all converted to lower case for HTTP/1.x.

There was an issue about adding http1_title_case_headers for clients: #1492 , but we don't have a way to preserve the response headers' title case from remote servers.

Some client applications are expecting to receive header with name that is exactly the same as the server returns, for example:

  • Nintendo Switch's connection checking will sent a GET request to http://ctest.cdn.nintendo.net/ and expecting a response with header X-Organization: Nintendo.
@seanmonstar
Copy link
Member

As always, I've suggest filing a bug with the thing that expects a certain casing, since in HTTP/1 header casing is defined as case-insensitive, and in HTTP2 and 3, it's forced to lowercase. So the Switch is definitely wrong here.

That said, I realize it's not always controllable, and so I'm exploring providing support in the C API for curl, and it might be possible to expose it as part of Rust's API as well... So far, my idea is to include an extra type in the request Extensions which is a mapping of HeaderNames to the original casing. If that type exists, it would use that to serialize instead of HeaderName, and then hyper would also collect a map for the response and put that in the response Extensions.

@seanmonstar seanmonstar added A-http1 Area: HTTP/1 specific. B-rfc Blocked: More comments would be useful in determine next steps. S-feature Severity: feature. This is adding a new feature. labels Nov 6, 2020
@nox
Copy link
Contributor

nox commented Mar 21, 2021

Isn't there now code to do that behind the ffi feature?

@seanmonstar
Copy link
Member

There is indeed code in hyper now, currently behind the ffi feature. If someone wants to contribute this, it'd be good to propose the API that is exposed to users, and then converting the code to be not just for the ffi feature.

nox added a commit to nox/hyper that referenced this issue Apr 8, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 8, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 8, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 8, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 8, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 9, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
@zonyitoo
Copy link
Contributor Author

PR: #2480

nox added a commit to nox/hyper that referenced this issue Apr 11, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 11, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 13, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 13, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 15, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 16, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 16, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 16, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 16, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 17, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 21, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 21, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
nox added a commit to nox/hyper that referenced this issue Apr 21, 2021
…#2313)

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.
zonyitoo added a commit to shadowsocks/shadowsocks-rust that referenced this issue Apr 23, 2021
zonyitoo added a commit to shadowsocks/shadowsocks-rust that referenced this issue Apr 23, 2021
BenxiangGe pushed a commit to BenxiangGe/hyper that referenced this issue Jul 26, 2021
Decouple preserving header case from FFI:

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.

Closes hyperium#2313
atkdef pushed a commit to atkdef/shadowsocks-rust that referenced this issue Sep 24, 2021
@seanmonstar seanmonstar removed the B-rfc Blocked: More comments would be useful in determine next steps. label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http1 Area: HTTP/1 specific. S-feature Severity: feature. This is adding a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants