| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 30af5ce commit 96f93cc
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1438,6 +1438,12 @@ Status code was outside the regular status code range (100-999). | |||
| 1438 | 1438 | ||
| 1439 | 1439 | The client has not sent the entire request within the allowed time. | |
| 1440 | 1440 | ||
| 1441 | + <a id="ERR_HTTP_SOCKET_ASSIGNED"></a> | ||
| 1442 | + | ||
| 1443 | + ### `ERR_HTTP_SOCKET_ASSIGNED` | ||
| 1444 | + | ||
| 1445 | + The given [`ServerResponse`][] was already assigned a socket. | ||
| 1446 | + | ||
| 1441 | 1447 | <a id="ERR_HTTP_SOCKET_ENCODING"></a> | |
| 1442 | 1448 | ||
| 1443 | 1449 | ### `ERR_HTTP_SOCKET_ENCODING` | |
@@ -3590,6 +3596,7 @@ The native call from `process.cpuUsage` could not be processed. | |||
| 3590 | 3596 | [`Object.getPrototypeOf`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf | |
| 3591 | 3597 | [`Object.setPrototypeOf`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf | |
| 3592 | 3598 | [`REPL`]: repl.md | |
| 3599 | + [`ServerResponse`]: http.md#class-httpserverresponse | ||
| 3593 | 3600 | [`Writable`]: stream.md#class-streamwritable | |
| 3594 | 3601 | [`child_process`]: child_process.md | |
| 3595 | 3602 | [`cipher.getAuthTag()`]: crypto.md#ciphergetauthtag | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,7 @@ const { | |||
| 75 | 75 | ERR_HTTP_HEADERS_SENT, | |
| 76 | 76 | ERR_HTTP_INVALID_STATUS_CODE, | |
| 77 | 77 | ERR_HTTP_SOCKET_ENCODING, | |
| 78 | + ERR_HTTP_SOCKET_ASSIGNED, | ||
| 78 | 79 | ERR_INVALID_ARG_VALUE, | |
| 79 | 80 | ERR_INVALID_CHAR, | |
| 80 | 81 | } = codes; | |
@@ -276,7 +277,9 @@ function onServerResponseClose() { | |||
| 276 | 277 | } | |
| 277 | 278 | ||
| 278 | 279 | ServerResponse.prototype.assignSocket = function assignSocket(socket) { | |
| 279 | - assert(!socket._httpMessage); | ||
| 280 | + if (socket._httpMessage) { | ||
| 281 | + throw new ERR_HTTP_SOCKET_ASSIGNED(); | ||
| 282 | + } | ||
| 280 | 283 | socket._httpMessage = this; | |
| 281 | 284 | socket.on('close', onServerResponseClose); | |
| 282 | 285 | this.socket = socket; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1167,6 +1167,8 @@ E('ERR_HTTP_INVALID_HEADER_VALUE', | |||
| 1167 | 1167 | 'Invalid value "%s" for header "%s"', TypeError); | |
| 1168 | 1168 | E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s', RangeError); | |
| 1169 | 1169 | E('ERR_HTTP_REQUEST_TIMEOUT', 'Request timeout', Error); | |
| 1170 | + E('ERR_HTTP_SOCKET_ASSIGNED', | ||
| 1171 | + 'ServerResponse has an already assigned socket', Error); | ||
| 1170 | 1172 | E('ERR_HTTP_SOCKET_ENCODING', | |
| 1171 | 1173 | 'Changing the socket encoding is not allowed per RFC7230 Section 3.', Error); | |
| 1172 | 1174 | E('ERR_HTTP_TRAILER_INVALID', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,4 +31,10 @@ const ws = new Writable({ | |||
| 31 | 31 | ||
| 32 | 32 | res.assignSocket(ws); | |
| 33 | 33 | ||
| 34 | + assert.throws(function() { | ||
| 35 | + res.assignSocket(ws); | ||
| 36 | + }, { | ||
| 37 | + code: 'ERR_HTTP_SOCKET_ASSIGNED' | ||
| 38 | + }); | ||
| 39 | + | ||
| 34 | 40 | res.end('hello world'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments