MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-http-response-no-headers.js:34–66  ·  view source on GitHub ↗
(httpVersion, callback)

Source from the content-addressed store, hash-verified

32};
33
34function test(httpVersion, callback) {
35 const server = net.createServer(function(conn) {
36 const reply = `HTTP/${httpVersion} 200 OK\r\n\r\n${expected[httpVersion]}`;
37
38 conn.end(reply);
39 });
40
41 server.listen(0, '127.0.0.1', common.mustCall(function() {
42 const options = {
43 host: '127.0.0.1',
44 port: this.address().port
45 };
46
47 const req = http.get(options, common.mustCall(function(res) {
48 let body = '';
49
50 res.on('data', function(data) {
51 body += data;
52 });
53
54 res.on('aborted', common.mustNotCall());
55 res.on('end', common.mustCall(function() {
56 assert.strictEqual(body, expected[httpVersion]);
57 server.close();
58 if (callback) process.nextTick(callback);
59 }));
60 }));
61
62 req.on('error', function(err) {
63 throw err;
64 });
65 }));
66}
67
68test('0.9', function() {
69 test('1.0', function() {

Calls 6

listenMethod · 0.80
addressMethod · 0.65
getMethod · 0.65
closeMethod · 0.65
endMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…