Skip to content

Commit 13389db

Browse files
committed
[test] Add core test-http-head-response-has-no-body-end test
Modifications: * make client connect to `PROXY_PORT` instead of `PORT`
1 parent f79f3ad commit 13389db

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
// libuv-broken
23+
24+
25+
var common = require('../common');
26+
var assert = require('assert');
27+
28+
var http = require('http');
29+
30+
// This test is to make sure that when the HTTP server
31+
// responds to a HEAD request with data to res.end,
32+
// it does not send any body.
33+
34+
var server = http.createServer(function(req, res) {
35+
res.writeHead(200);
36+
res.end('FAIL'); // broken: sends FAIL from hot path.
37+
});
38+
server.listen(common.PORT);
39+
40+
var responseComplete = false;
41+
42+
server.on('listening', function() {
43+
var req = http.request({
44+
port: common.PROXY_PORT,
45+
method: 'HEAD',
46+
path: '/'
47+
}, function(res) {
48+
common.error('response');
49+
res.on('end', function() {
50+
common.error('response end');
51+
server.close();
52+
responseComplete = true;
53+
});
54+
});
55+
common.error('req');
56+
req.end();
57+
});
58+
59+
process.on('exit', function() {
60+
assert.ok(responseComplete);
61+
});

0 commit comments

Comments
 (0)