lukeed / polka

A micro web server so fast, it'll make you dance! :dancers:
MIT License
5.43k stars 174 forks source link

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

Closed BenjaminGlusa closed 3 years ago

BenjaminGlusa commented 3 years ago

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); });


2. Send request (e.g. with curl): ```curl -v http://localhost:8085/test```

**Expected Result**
Response header `content-length`is 0 or unset

**Actual Result**
Response header `content-length`is 10

**Impact**
Some rest clients (postman) will wait 5 seconds for the content to be received.
lukeed commented 3 years ago

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!