Skip to content

Headers with the same name are combined into one entry in http2 #35658

@triblondon

Description

@triblondon

Version: 14.13.1
Platform: macOS, Darwin Kernel Version 19.6.0

What steps will reproduce the bug?

$ node
Welcome to Node.js v14.13.1.
Type ".help" for more information.
> (() => {
...   const http2 = require("http2");
...   const client = http2.connect("https://www.httpbin.org");
...   const req = client.request({ ":path": "/response-headers?foo=42&foo=43&foo=44" });
...   req.on("response", (headers, flags) => console.log("Response:", headers, flags));
...   req.on("end", () => client.close());
...   req.end();
... })();
undefined
> Response: [Object: null prototype] {
  ':status': 200,
  date: 'Thu, 15 Oct 2020 14:15:24 GMT',
  'content-type': 'application/json',
  'content-length': '117',
  server: 'gunicorn/19.9.0',
  foo: '42, 43, 44',
  'access-control-allow-origin': '*',
  'access-control-allow-credentials': 'true'
} 4

Versus cURL on the same URL:

$ curl -i "https://httpbin.org/response-headers?Foo=42&Foo=43&Foo=44"
HTTP/2 200 
date: Thu, 15 Oct 2020 12:58:56 GMT
content-type: application/json
content-length: 117
server: gunicorn/19.9.0
foo: 42
foo: 43
foo: 44
access-control-allow-origin: *
access-control-allow-credentials: true

...body...

How often does it reproduce? Is there a required condition?

Consistently reproducible

What is the expected behavior?

foo: ['42', '43', '44'],

Quoting the docs:

Headers are represented as own-properties on JavaScript objects. The property keys will be serialized to lower-case. Property values should be strings (if they are not they will be coerced to strings) or an Array of strings (in order to send more than one value per header field).

What do you see instead?

foo: '42, 43, 44',

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions