This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server responses should have a body if HEAD request
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
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,31 @@ | ||
require('../common'); | ||
|
||
var http = require('http'); | ||
|
||
// This test is to make sure that when the HTTP server | ||
// responds to a HEAD request, it does not send any body. | ||
// In this case it was sending '0\r\n\r\n' | ||
|
||
var server = http.createServer(function(req, res) { | ||
res.writeHead(200); // broken: defaults to TE chunked | ||
res.end(); | ||
}); | ||
server.listen(PORT); | ||
|
||
responseComplete = false; | ||
|
||
var req = http.createClient(PORT).request('HEAD', '/') | ||
error('req'); | ||
req.end(); | ||
req.addListener('response', function (res) { | ||
error('response'); | ||
res.addListener('end', function() { | ||
error('response end'); | ||
server.close(); | ||
responseComplete = true; | ||
}); | ||
}); | ||
|
||
process.addListener('exit', function () { | ||
assert.ok(responseComplete); | ||
}); |