| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 67fb765 commit eb19b1e
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1309,8 +1309,9 @@ type other than {net.Socket}. | |||
| 1309 | 1309 | ||
| 1310 | 1310 | Default behavior is to try close the socket with a HTTP '400 Bad Request', | |
| 1311 | 1311 | or a HTTP '431 Request Header Fields Too Large' in the case of a | |
| 1312 | - [`HPE_HEADER_OVERFLOW`][] error. If the socket is not writable or has already | ||
| 1313 | - written data it is immediately destroyed. | ||
| 1312 | + [`HPE_HEADER_OVERFLOW`][] error. If the socket is not writable or headers | ||
| 1313 | + of the current attached [`http.ServerResponse`][] has been sent, it is | ||
| 1314 | + immediately destroyed. | ||
| 1314 | 1315 | ||
| 1315 | 1316 | `socket` is the [`net.Socket`][] object that the error originated from. | |
| 1316 | 1317 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -819,7 +819,11 @@ function socketOnError(e) { | |||
| 819 | 819 | } | |
| 820 | 820 | ||
| 821 | 821 | if (!this.server.emit('clientError', e, this)) { | |
| 822 | - if (this.writable && this.bytesWritten === 0) { | ||
| 822 | + // Caution must be taken to avoid corrupting the remote peer. | ||
| 823 | + // Reply an error segment if there is no in-flight `ServerResponse`, | ||
| 824 | + // or no data of the in-flight one has been written yet to this socket. | ||
| 825 | + if (this.writable && | ||
| 826 | + (!this._httpMessage || !this._httpMessage._headerSent)) { | ||
| 823 | 827 | let response; | |
| 824 | 828 | ||
| 825 | 829 | switch (e.code) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,9 +81,7 @@ server.listen(0, common.mustCall(() => { | |||
| 81 | 81 | assert.strictEqual(second, true); | |
| 82 | 82 | assert.strictEqual( | |
| 83 | 83 | response, | |
| 84 | - // Empty because of https://github.com/nodejs/node/commit/e8d7fedf7cad6e612e4f2e0456e359af57608ac7 | ||
| 85 | - // 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 86 | - '' | ||
| 84 | + 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 87 | 85 | ); | |
| 88 | 86 | server.close(); | |
| 89 | 87 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,9 +56,7 @@ server.listen(0, common.mustCall(() => { | |||
| 56 | 56 | ||
| 57 | 57 | assert.strictEqual( | |
| 58 | 58 | response, | |
| 59 | - // Empty because of https://github.com/nodejs/node/commit/e8d7fedf7cad6e612e4f2e0456e359af57608ac7 | ||
| 60 | - // 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 61 | - '' | ||
| 59 | + 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 62 | 60 | ); | |
| 63 | 61 | server.close(); | |
| 64 | 62 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,9 +79,7 @@ server.listen(0, common.mustCall(() => { | |||
| 79 | 79 | assert.strictEqual(second, true); | |
| 80 | 80 | assert.strictEqual( | |
| 81 | 81 | response, | |
| 82 | - // Empty because of https://github.com/nodejs/node/commit/e8d7fedf7cad6e612e4f2e0456e359af57608ac7 | ||
| 83 | - // 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 84 | - '' | ||
| 82 | + 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 85 | 83 | ); | |
| 86 | 84 | server.close(); | |
| 87 | 85 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,9 +50,7 @@ server.listen(0, common.mustCall(() => { | |||
| 50 | 50 | ||
| 51 | 51 | assert.strictEqual( | |
| 52 | 52 | response, | |
| 53 | - // Empty because of https://github.com/nodejs/node/commit/e8d7fedf7cad6e612e4f2e0456e359af57608ac7 | ||
| 54 | - // 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 55 | - '' | ||
| 53 | + 'HTTP/1.1 408 Request Timeout\r\nConnection: close\r\n\r\n' | ||
| 56 | 54 | ); | |
| 57 | 55 | server.close(); | |
| 58 | 56 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments