lukeed/polka

send-type sets header content-length when status code is 204 (no-content)

Closed this issue · 1 comments

** Affected version **
"@polka/send-type": "0.5.2",
"polka": "0.5.2"

Steps to reproduce:

  1. Start polka webserver:
const polka = require('polka');
const send = require('@polka/send-type');

const app = polka().listen(8085, err => {
  if (err) throw err;
  console.log(`> Running on localhost: 8085`);
});

app.get('/test', (req, res) => {
  send(res, 204);
});
  1. Send request (e.g. with curl): curl -v http://localhost:8085/test

Expected Result
Response header content-lengthis 0 or unset

Actual Result
Response header content-lengthis 10

Impact
Some rest clients (postman) will wait 5 seconds for the content to be received.

Hey,

This is solved in @polka/send@next: https://github.com/lukeed/polka/blob/next/packages/send/index.js#L41-L46
(For the next version, @polka/send-type has been renamed to @polka/send)

You can actually use that package today without updating anything else to its next variant.

Thank you for the report though!