Skip to content
Myr

Support proper 205 responses using res.send

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #4592 closes #4596

authored by Tito D. Kesumo Siregar · committed by Douglas Christopher Wilson · parent 8bf0720 · Browse files · 3 files+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+28 added−0 removed

  • tests:+16 added−0 removed
  • other:+12 added−0 removed

3 files+28 added−0 removed

modified:lib/response.js+7 added
211 unmodified lines
212 this.removeHeader('Transfer-Encoding');213 chunk = '';214 }215216 // alter headers for 205217 if (this.statusCode === 205) {218 this.set('Content-Length', '0')219 this.removeHeader('Transfer-Encoding')220 chunk = ''221 }222223 if (req.method === 'HEAD') {224 // skip body for HEAD225 this.end();226 } else {
928 unmodified lines
modified:test/res.send.js+16 added
281 unmodified lines
282 .expect(204, '', done);283 })284 })285286 describe('when .statusCode is 205', function () {287 it('should strip Transfer-Encoding field and body, set Content-Length', function (done) {288 var app = express()289290 app.use(function (req, res) {291 res.status(205).set('Transfer-Encoding', 'chunked').send('foo')292 })293294 request(app)295 .get('/')296 .expect(utils.shouldNotHaveHeader('Transfer-Encoding'))297 .expect('Content-Length', '0')298 .expect(205, '', done)299 })300 })301302 describe('when .statusCode is 304', function(){303 it('should strip Content-* fields, Transfer-Encoding field, and body', function(done){304 var app = express();305
291 unmodified lines
modified:History.md+5 added
1unreleased2==========34 * Support proper 205 responses using `res.send`564.17.3 / 2022-02-167===================89 * deps: accepts@~1.3.8
3521 unmodified lines