Skip to content

support nested headers in http2Β #33568

@rexagod

Description

@rexagod

Actual Behaviour
For the snippet given below, http1 returns ['A','B'], but http2 returns only ['B'].

res.writeHead(200, [['set-cookie', 'A'],
                    ['set-cookie', 'B'],
                    ['content-type', 'text/plain']]);

Expected Behavior
http2 should return ['A','B'].

Reproduction Code

const server = http2.createServer(function (req, res) {
  res.writeHead(200, [['set-cookie', 'A'],
                        ['set-cookie', 'B'],
                        ['content-type', 'text/plain']]);
  res.end();
});

server.listen(0, () => {
  const url = `http://localhost:${server.address().port}`;
  const clientsession = http2.connect(url);
  const req = clientsession.request();
  req.on('response', (headers) => {
    assert.deepStrictEqual(headers['set-cookie'], ['A', 'B']); // fails
  });
  req.on('end', () => {
    clientsession.close();
    server.close();
  });
});

I think this is caused by an unintentional override inside kSetHeaders method, see below.

this[kHeaders][name] = value;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions