| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5ca437b commit 4b2a015
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1431,6 +1431,12 @@ Status code was outside the regular status code range (100-999). | |||
| 1431 | 1431 | ||
| 1432 | 1432 | The client has not sent the entire request within the allowed time. | |
| 1433 | 1433 | ||
| 1434 | + <a id="ERR_HTTP_SOCKET_ASSIGNED"></a> | ||
| 1435 | + | ||
| 1436 | + ### `ERR_HTTP_SOCKET_ASSIGNED` | ||
| 1437 | + | ||
| 1438 | + The given [`ServerResponse`][] was already assigned a socket. | ||
| 1439 | + | ||
| 1434 | 1440 | <a id="ERR_HTTP_SOCKET_ENCODING"></a> | |
| 1435 | 1441 | ||
| 1436 | 1442 | ### `ERR_HTTP_SOCKET_ENCODING` | |
@@ -3565,6 +3571,7 @@ The native call from `process.cpuUsage` could not be processed. | |||
| 3565 | 3571 | [`Object.getPrototypeOf`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf | |
| 3566 | 3572 | [`Object.setPrototypeOf`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf | |
| 3567 | 3573 | [`REPL`]: repl.md | |
| 3574 | + [`ServerResponse`]: http.md#class-httpserverresponse | ||
| 3568 | 3575 | [`Writable`]: stream.md#class-streamwritable | |
| 3569 | 3576 | [`child_process`]: child_process.md | |
| 3570 | 3577 | [`cipher.getAuthTag()`]: crypto.md#ciphergetauthtag | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,7 @@ const { | |||
| 76 | 76 | ERR_HTTP_INVALID_STATUS_CODE, | |
| 77 | 77 | ERR_HTTP_SOCKET_ENCODING, | |
| 78 | 78 | ERR_INVALID_ARG_TYPE, | |
| 79 | + ERR_HTTP_SOCKET_ASSIGNED, | ||
| 79 | 80 | ERR_INVALID_ARG_VALUE, | |
| 80 | 81 | ERR_INVALID_CHAR, | |
| 81 | 82 | } = codes; | |
@@ -279,7 +280,9 @@ function onServerResponseClose() { | |||
| 279 | 280 | } | |
| 280 | 281 | ||
| 281 | 282 | ServerResponse.prototype.assignSocket = function assignSocket(socket) { | |
| 282 | - assert(!socket._httpMessage); | ||
| 283 | + if (socket._httpMessage) { | ||
| 284 | + throw new ERR_HTTP_SOCKET_ASSIGNED(); | ||
| 285 | + } | ||
| 283 | 286 | socket._httpMessage = this; | |
| 284 | 287 | socket.on('close', onServerResponseClose); | |
| 285 | 288 | 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