#876·supertest

[fix] content-type with "header=" breaks all header matchers

Author: davidje13Created Jan 7, 2026Updated Jan 7, 2026
Labelsbug

Describe the bug

Node.js version: v24.10.0

OS version: macOS 15.7.3

Description:

If a response contains a Content-Type header with header=(anything), header matching breaks for all headers. This is relevant to text/csv responses, which can contain header=present or header=absent.

Actual behavior

Expectations fail with expected "..." header field (see full output below)

Expected behavior

Other headers are not affected by content-type parameters.

Code to reproduce

javascript
import request from 'supertest';
import { createServer } from 'node:http';

const s = createServer((_, res) => {
  res.setHeader('foo', 'a');
  res.setHeader('content-type', 'text/csv; header=a');
  res.end();
});
await new Promise((resolve) => s.listen(0, '127.0.0.1', resolve));

await request(s).get('/').expect(200).expect('foo', 'a');
Error: expected "foo" header field
    at file://[...]/experiment.js:11:39
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
----
    at Test._assertHeader ([...]/node_modules/supertest/lib/test.js:281:47)
    at [...]/node_modules/supertest/lib/test.js:365:13
    at Test._assertFunction ([...]/node_modules/supertest/lib/test.js:342:13)
    at Test.assert ([...]/node_modules/supertest/lib/test.js:195:23)
    at localAssert ([...]/node_modules/supertest/lib/test.js:138:14)
    at [...]/node_modules/supertest/lib/test.js:156:7
    at Request.callback ([...]/node_modules/superagent/lib/node/index.js:847:12)
    at IncomingMessage.<anonymous> ([...]/node_modules/superagent/lib/node/index.js:1102:18)
    at IncomingMessage.emit (node:events:520:35)
    at endReadableNT (node:internal/streams/readable:1701:12)

Removing or renaming header=a in the content-type header, or renaming the content-type header to any other name, causes the issue to go away.

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.