| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ec8a996 commit 2f1d231
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,32 +12,35 @@ var net = require('net'); | |||
| 12 | 12 | // Likewise for 304 responses. Verify that no empty chunk is sent when | |
| 13 | 13 | // the user explicitly sets a Transfer-Encoding header. | |
| 14 | 14 | ||
| 15 | - test(204, function() { | ||
| 16 | - test(304); | ||
| 17 | - }); | ||
| 15 | + test(204); | ||
| 16 | + test(304); | ||
| 18 | 17 | ||
| 19 | - function test(statusCode, next) { | ||
| 20 | - var server = http.createServer(function(req, res) { | ||
| 18 | + function test(statusCode) { | ||
| 19 | + const server = http.createServer(common.mustCall((req, res) => { | ||
| 21 | 20 | res.writeHead(statusCode, { 'Transfer-Encoding': 'chunked' }); | |
| 22 | 21 | res.end(); | |
| 23 | 22 | server.close(); | |
| 24 | - }); | ||
| 23 | + })); | ||
| 25 | 24 | ||
| 26 | - server.listen(0, function() { | ||
| 27 | - var conn = net.createConnection(this.address().port, function() { | ||
| 28 | - conn.write('GET / HTTP/1.1\r\n\r\n'); | ||
| 25 | + server.listen(0, common.mustCall(() => { | ||
| 26 | + const conn = net.createConnection( | ||
| 27 | + server.address().port, | ||
| 28 | + common.mustCall(() => { | ||
| 29 | + conn.write('GET / HTTP/1.1\r\n\r\n'); | ||
| 29 | 30 | ||
| 30 | - var resp = ''; | ||
| 31 | - conn.setEncoding('utf8'); | ||
| 32 | - conn.on('data', function(data) { | ||
| 33 | - resp += data; | ||
| 34 | - }); | ||
| 31 | + let resp = ''; | ||
| 32 | + conn.setEncoding('utf8'); | ||
| 33 | + conn.on('data', common.mustCall((data) => { | ||
| 34 | + resp += data; | ||
| 35 | + })); | ||
| 35 | 36 | ||
| 36 | - conn.on('end', common.mustCall(function() { | ||
| 37 | - assert.equal(/^Connection: close\r\n$/m.test(resp), true); | ||
| 38 | - assert.equal(/^0\r\n$/m.test(resp), false); | ||
| 39 | - if (next) process.nextTick(next); | ||
| 40 | - })); | ||
| 41 | - }); | ||
| 42 | - }); | ||
| 37 | + conn.on('end', common.mustCall(() => { | ||
| 38 | + // Connection: close should be in the response | ||
| 39 | + assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true); | ||
| 40 | + // Make sure this doesn't end with 0\r\n\r\n | ||
| 41 | + assert.strictEqual(/^0\r\n$/m.test(resp), false); | ||
| 42 | + })); | ||
| 43 | + }) | ||
| 44 | + ); | ||
| 45 | + })); | ||
| 43 | 46 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments