Skip to content

Commit

Permalink
fix request with content-length > 0 and content-encoding: gzip (#371)
Browse files Browse the repository at this point in the history
* test that head method works correctly

* uppercase methods sent to Request instance\n fixes head with content-length > 0 amongst other things
  • Loading branch information
seangarner authored and mikelax committed Oct 19, 2016
1 parent cf9f991 commit e07e981
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions test/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,26 @@ describe('.<http verb> 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() {
Expand Down

0 comments on commit e07e981

Please sign in to comment.