gaxios icon indicating copy to clipboard operation
gaxios copied to clipboard

case sensitivity of headers should not matter

Open bcoe opened this issue 4 years ago • 4 comments

Currently if one were to set a "content-type" header and a "Content-Type" header, the two are not equivalent.

I've seen libraries like express approach this differently, such that headers are case-insensitive.

bcoe avatar Mar 24 '20 00:03 bcoe

Headers are case-insensitive according to RFC2616 so this is a bug, not a feature request, in my opinion.

kungfutse avatar Apr 30 '20 12:04 kungfutse

I'm not sure what the actual bug is here :) Can someone give me an example? Right now the request.Headers field is just a POJO.

For example:

const options: GaxiosOptions = { 
  headers: {
    'content-type': 'application/json',
    'Content-Type': 'text/xml',
  },
},

We could look for this situation and throw if we find duplicate keys once lower cased?

JustinBeckwith avatar May 02 '20 19:05 JustinBeckwith

@JustinBeckwith a warning might be enough, but I think a cleaning step that lowercases headers would be good, that way upstream libraries that build on top of gaxios, e.g., google-auth-library need not check every combination of a given header.

bcoe avatar May 06 '20 23:05 bcoe