-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: send implicit headers on HEAD with no body
If we respond to a HEAD request with a body, we ignore all writes. However, we must still include all implicit headers. Fixes a regressions introduced in #47732. Signed-off-by: Matteo Collina <[email protected]> PR-URL: #48108 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Marco Ippolito <[email protected]>
- Loading branch information
Showing
3 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/parallel/test-http-head-response-has-no-body-end-implicit-headers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
|
||
// This test is to make sure that when the HTTP server | ||
// responds to a HEAD request with data to res.end, | ||
// it does not send any body but the response is sent | ||
// anyway. | ||
|
||
const server = http.createServer(function(req, res) { | ||
res.end('FAIL'); // broken: sends FAIL from hot path. | ||
}); | ||
server.listen(0); | ||
|
||
server.on('listening', common.mustCall(function() { | ||
const req = http.request({ | ||
port: this.address().port, | ||
method: 'HEAD', | ||
path: '/' | ||
}, common.mustCall(function(res) { | ||
res.on('end', common.mustCall(function() { | ||
server.close(); | ||
})); | ||
res.resume(); | ||
})); | ||
req.end(); | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters