grape icon indicating copy to clipboard operation
grape copied to clipboard

Allow lowercase HTTP/2 headers

Open pre opened this issue 3 years ago • 1 comments

HTTP/2 defines that HTTP headers be lowercase.

Grape consistently normalizes HTTP headers to PascalCase. This is ok since it's consistent.

However, there are more and more API clients which normalize HTTP headers to lowercase. One example is Axios.

This means that the exact same HTTP header name cannot be used as-is at the Grape API and Client side, since both implement a normalization of their own.

For example Rack provides Rack::Headers middleware which normalizes HTTP headers to lowercase per HTTP/2. It also seems the upcoming Rack 3 will provide lowercased HTTP headers by default.

I suggest an option to somehow enable HTTP header normalization to lowercase in Grape.

References:

  • https://github.com/rack/rack/issues/1592
  • https://github.com/rack/rack/pull/1800

pre avatar Mar 02 '22 15:03 pre

See https://github.com/ruby-grape/grape/pull/2355 for a beginning of solving this.

dblock avatar Oct 21 '23 14:10 dblock