From e07e9819e917a8b3fe8245d7a7fbc7286e8fe8d0 Mon Sep 17 00:00:00 2001 From: Sean Garner Date: Wed, 19 Oct 2016 14:52:22 +0100 Subject: [PATCH] fix request with content-length > 0 and content-encoding: gzip (#371) * test that head method works correctly * uppercase methods sent to Request instance\n fixes head with content-length > 0 amongst other things --- lib/test.js | 2 +- test/supertest.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/test.js b/lib/test.js index 55231b6c..21cc64eb 100644 --- a/lib/test.js +++ b/lib/test.js @@ -26,7 +26,7 @@ module.exports = Test; */ function Test(app, method, path) { - Request.call(this, method, path); + Request.call(this, method.toUpperCase(), path); this.redirects(0); this.buffer(); this.app = app; diff --git a/test/supertest.js b/test/supertest.js index 75b03ff2..c9a4927b 100644 --- a/test/supertest.js +++ b/test/supertest.js @@ -866,6 +866,26 @@ describe('. works as expected', function() { .put('/') .expect(200, done); }); + it('.head should work', function (done) { + var app = express(); + app.head('/', function(req, res) { + res.statusCode = 200; + res.set('Content-Encoding', 'gzip'); + res.set('Content-Length', '1024'); + res.status(200); + res.end(); + }); + + request(app) + .head('/') + .set('accept-encoding', 'gzip, deflate') + .end(function (err, res) { + if (err) return done(err); + res.should.have.property('statusCode', 200); + res.headers.should.have.property('content-length', '1024'); + done(); + }); + }); }); describe('assert ordering by call order', function() {