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

Function test

test/parallel/test-http-chunked-304.js:39–67  ·  view source on GitHub ↗
(statusCode)

Source from the content-addressed store, hash-verified

37test(304);
38
39function test(statusCode) {
40 const server = http.createServer(common.mustCall((req, res) => {
41 res.writeHead(statusCode, { 'Transfer-Encoding': 'chunked' });
42 res.end();
43 server.close();
44 }));
45
46 server.listen(0, common.mustCall(() => {
47 const conn = net.createConnection(
48 server.address().port,
49 common.mustCall(() => {
50 conn.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
51
52 let resp = '';
53 conn.setEncoding('utf8');
54 conn.on('data', common.mustCall((data) => {
55 resp += data;
56 }));
57
58 conn.on('end', common.mustCall(() => {
59 // Connection: close should be in the response
60 assert.match(resp, /^Connection: close\r\n$/m);
61 // Make sure this doesn't end with 0\r\n\r\n
62 assert.doesNotMatch(resp, /^0\r\n$/m);
63 }));
64 })
65 );
66 }));
67}

Callers 1

Calls 10

writeHeadMethod · 0.80
listenMethod · 0.80
closeMethod · 0.65
addressMethod · 0.65
matchMethod · 0.65
endMethod · 0.45
createConnectionMethod · 0.45
writeMethod · 0.45
setEncodingMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…