Search code examples
node.jsexpresscontent-type

How can I unset the content-type header with express


I am using express-js (4) as a test server, and it needs to behave similar to the real server. The real server doesn't always send a content-type header, so I need to make the express server do the same thing.

  res.set('Content-Type', undefined);
  res.send('test get');

gives me 'invalid media type'

Is there any way to tell it not to send a content-type header?


Solution

  • if anybody else is interested, to send with no content-type header, just use res.end instead of res.send

    res.end('test get');