Skip to content

multi-value content-disposition header value results in invalid header value #50978

@ArsalanDotMe

Description

@ArsalanDotMe

Version

v20.8.0

Platform

Darwin A-KM20V94RKQ 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

Subsystem

http

What steps will reproduce the bug?

const http = require('http');

const server = http.createServer((req, res) => {
  if (req.url === '/api/works') {
    const someString = 'Hello world!';
    const buffer = Buffer.from(someString, 'utf8');
    res.setHeader('Content-Disposition', 'attachment; filename="hello.txt"');
    res.end(buffer);
  } else if (req.url === '/api/fails') {
    const someString = 'Hello world!';
    const buffer = Buffer.from(someString, 'utf8');
    res.setHeader('Content-Disposition', ['attachment; filename="hello.txt"']);
    // returns ERR_INVALID_HTTP_RESPONSE in Chrome, fails with a 502 on ALB
    res.end(buffer);
  }
});

const port = 3000;
server.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});

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

It is always reproducible.

What is the expected behavior? Why is that the expected behavior?

Expected behavior is that an array can be passed as a value for the content-disposition header just like any other header.

What do you see instead?

Passing an array as a value to content-disposition header results in invalid header value.

Additional information

Issue introduced by #46528

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