gloo icon indicating copy to clipboard operation
gloo copied to clipboard

headers are all set to lowercase

Open makerio90 opened this issue 3 years ago • 5 comments

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 avatar Oct 17 '22 02:10 makerio90

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

ctjhoa avatar Nov 13 '22 08:11 ctjhoa

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

makerio90 avatar Nov 14 '22 22:11 makerio90

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

ranile avatar Jan 21 '23 10:01 ranile

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.

Dyhr avatar Jan 23 '23 13:01 Dyhr

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

futursolo avatar Jan 23 '23 13:01 futursolo