| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f61dcc4 commit 1a78bde
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,13 @@ const server = http.createServer(function(request, response) { | |||
| 10 | 10 | // For HTTP/1.0, the connection should be closed after the response automatically. | |
| 11 | 11 | response.removeHeader('connection'); | |
| 12 | 12 | ||
| 13 | + if (request.httpVersion === '1.0') { | ||
| 14 | + const socket = request.socket; | ||
| 15 | + response.on('finish', common.mustCall(function() { | ||
| 16 | + assert.ok(socket.writableEnded); | ||
| 17 | + })); | ||
| 18 | + } | ||
| 19 | + | ||
| 13 | 20 | response.end('beep boop\n'); | |
| 14 | 21 | }); | |
| 15 | 22 | ||
@@ -50,9 +57,7 @@ function makeHttp10Request(cb) { | |||
| 50 | 57 | '\r\n'); | |
| 51 | 58 | socket.resume(); // Ignore the response itself | |
| 52 | 59 | ||
| 53 | - setTimeout(function() { | ||
| 54 | - cb(socket); | ||
| 55 | - }, common.platformTimeout(50)); | ||
| 60 | + socket.on('close', cb); | ||
| 56 | 61 | }); | |
| 57 | 62 | } | |
| 58 | 63 | ||
@@ -62,9 +67,7 @@ server.listen(0, function() { | |||
| 62 | 67 | // Both HTTP/1.1 requests should have used the same socket: | |
| 63 | 68 | assert.strictEqual(firstSocket, secondSocket); | |
| 64 | 69 | ||
| 65 | - makeHttp10Request(function(socket) { | ||
| 66 | - // The server should have immediately closed the HTTP/1.0 socket: | ||
| 67 | - assert.strictEqual(socket.closed, true); | ||
| 70 | + makeHttp10Request(function() { | ||
| 68 | 71 | server.close(); | |
| 69 | 72 | }); | |
| 70 | 73 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments