You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP2 writehead header format can't use array of arrays for headers #24466
With http, you can send headers like this:
[
[
"Content-Type",
"text/html; charset=utf-8"
],
[
"last-modified",
"Sun, 18 Nov 2018 17:49:47 GMT"
]
]
To send multiple values for the same header, like cookies. But with http2 the returned headers looks like this when this format is used: https://i.imgur.com/QXZnu4v.png
I can confirm this diverging behaviour. However the documentation for http.writeHead does not describe the Array of Arrays use case. Should this be supported?
Details
consthttp=require('http')consthttp2=require('http2')constheaders=[['Content-Type','text/html; charset=utf-8'],['last-modified','Sun, 18 Nov 2018 17:49:47 GMT']]http.createServer((request,response)=>{console.log(`Request via HTTP/${request.httpVersion}`)response.writeHead(200,headers)response.end()}).listen(8001)http2.createServer((request,response)=>{console.log(`Request via HTTP/${request.httpVersion}`)response.writeHead(200,headers)response.end()}).listen(8002)
$ curl -v http://localhost:8001
* Rebuilt URL to: http://localhost:8001/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8001 (#0)
> GET / HTTP/1.1
> Host: localhost:8001
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< last-modified: Sun, 18 Nov 2018 17:49:47 GMT
< Date: Mon, 26 Nov 2018 02:44:23 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
$ curl -v --http2-prior-knowledge http://localhost:8002
* Rebuilt URL to: http://localhost:8002/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8002 (#0)
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f8f85000400)
> GET / HTTP/2
> Host: localhost:8002
> User-Agent: curl/7.54.0
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< 0: Content-Type
< 0: text/html; charset=utf-8
< 1: last-modified
< 1: Sun, 18 Nov 2018 17:49:47 GMT
< date: Mon, 26 Nov 2018 02:32:38 GMT
<
* Connection #0 to host localhost left intact
A suggestion: deprecate the nested array format starting off node 11after implementing parity. You can already achieve the same functionality trough the documented means, which is what I did.
Activity
Trott commentedon Nov 25, 2018
@nodejs/http2
sebdeckers commentedon Nov 26, 2018
I can confirm this diverging behaviour. However the documentation for
http.writeHeaddoes not describe the Array of Arrays use case. Should this be supported?Details
jasnell commentedon Nov 26, 2018
Unfortunately, we probably should support it.
StephenLynx commentedon Nov 29, 2018
A suggestion: deprecate the nested array format starting off node 11after implementing parity. You can already achieve the same functionality trough the documented means, which is what I did.
http2: add compat support for nested array headers
http2: add compat support for nested array headers
http2: add compat support for nested array headers
http2: add compat support for nested array headers
http2: add compat support for nested array headers