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

headers are all set to lowercase #258

Open
makerio90 opened this issue Oct 17, 2022 · 5 comments
Open

headers are all set to lowercase #258

makerio90 opened this issue Oct 17, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@makerio90
Copy link

makerio90 commented Oct 17, 2022

Describe the Bug

i am trying to make a HTTP POST request to an API with a specific header set, but the header gets set to all lowercase at some point

Steps to Reproduce

  1. create code that makes a HTTP request, ie
Request::post("/auth/login")
                        .header("TEstHeadEr", "MyVAlUe")
                        .send()
                        .await;
  1. send it
  2. open browser console
  3. open request you just sent
  4. there should be a header named testheader: MyVAlUe
    (note the diffrence in case)

Expected Behavior

header set should match the case of whats defined in the code.

Actual Behavior

header is always lowercase, regardless of code

Additional Context

tested on chromium and firefox; same thing

@makerio90 makerio90 added the bug Something isn't working label Oct 17, 2022
@ctjhoa
Copy link

ctjhoa commented Nov 13, 2022

Http header are case insensitive
https://stackoverflow.com/a/5259004
So this should not be an issue IMO.

@makerio90
Copy link
Author

it doesn't matter. you cant grantee the server your communicating with is also going to be case insensitive

@hamza1311
Copy link
Collaborator

Can you confirm that fetch also does that? Gloo exposes the Headers interface and does no pre-processing

@Dyhr
Copy link

Dyhr commented Jan 23, 2023

it doesn't matter. you cant grantee the server your communicating with is also going to be case insensitive

If the server isn't compliant with the spec then you don't have any guarantees at all. If you have a bug where this is an issue, then this ticket belongs with the server, not here.

Compliance aside, I do agree with the spirit of keeping the case as specified.

@futursolo
Copy link
Collaborator

futursolo commented Jan 23, 2023

If you use HTTP 2.0, the browser will turn all headers to lowercase. This is enforced by your browser and cannot be worked around.

However, header field names MUST be converted to lowercase prior to their encoding in HTTP/2. A request or response containing uppercase header field names MUST be treated as malformed

See: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants