(statusCode)
| 37 | test(304); |
| 38 | |
| 39 | function 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 | } |
no test coverage detected
searching dependent graphs…