| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 21dd601 commit b775753
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,7 +157,7 @@ added: v0.11.4 | |||
| 157 | 157 | * `options` {Object} Options containing connection details. Check | |
| 158 | 158 | [`net.createConnection()`][] for the format of the options | |
| 159 | 159 | * `callback` {Function} Callback function that receives the created socket | |
| 160 | - * Returns: {net.Socket} | ||
| 160 | + * Returns: {stream.Duplex} | ||
| 161 | 161 | ||
| 162 | 162 | Produces a socket/stream to be used for HTTP requests. | |
| 163 | 163 | ||
@@ -167,14 +167,18 @@ custom agents may override this method in case greater flexibility is desired. | |||
| 167 | 167 | A socket/stream can be supplied in one of two ways: by returning the | |
| 168 | 168 | socket/stream from this function, or by passing the socket/stream to `callback`. | |
| 169 | 169 | ||
| 170 | + This method is guaranteed to return an instance of the {net.Socket} class, | ||
| 171 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 172 | + type other than {net.Socket}. | ||
| 173 | + | ||
| 170 | 174 | `callback` has a signature of `(err, stream)`. | |
| 171 | 175 | ||
| 172 | 176 | ### agent.keepSocketAlive(socket) | |
| 173 | 177 | <!-- YAML | |
| 174 | 178 | added: v8.1.0 | |
| 175 | 179 | --> | |
| 176 | 180 | ||
| 177 | - * `socket` {net.Socket} | ||
| 181 | + * `socket` {stream.Duplex} | ||
| 178 | 182 | ||
| 179 | 183 | Called when `socket` is detached from a request and could be persisted by the | |
| 180 | 184 | `Agent`. Default behavior is to: | |
@@ -189,12 +193,15 @@ This method can be overridden by a particular `Agent` subclass. If this | |||
| 189 | 193 | method returns a falsy value, the socket will be destroyed instead of persisting | |
| 190 | 194 | it for use with the next request. | |
| 191 | 195 | ||
| 196 | + The `socket` argument can be an instance of {net.Socket}, a subclass of | ||
| 197 | + {stream.Duplex}. | ||
| 198 | + | ||
| 192 | 199 | ### agent.reuseSocket(socket, request) | |
| 193 | 200 | <!-- YAML | |
| 194 | 201 | added: v8.1.0 | |
| 195 | 202 | --> | |
| 196 | 203 | ||
| 197 | - * `socket` {net.Socket} | ||
| 204 | + * `socket` {stream.Duplex} | ||
| 198 | 205 | * `request` {http.ClientRequest} | |
| 199 | 206 | ||
| 200 | 207 | Called when `socket` is attached to `request` after being persisted because of | |
@@ -206,6 +213,9 @@ socket.ref(); | |||
| 206 | 213 | ||
| 207 | 214 | This method can be overridden by a particular `Agent` subclass. | |
| 208 | 215 | ||
| 216 | + The `socket` argument can be an instance of {net.Socket}, a subclass of | ||
| 217 | + {stream.Duplex}. | ||
| 218 | + | ||
| 209 | 219 | ### agent.destroy() | |
| 210 | 220 | <!-- YAML | |
| 211 | 221 | added: v0.11.4 | |
@@ -341,13 +351,17 @@ added: v0.7.0 | |||
| 341 | 351 | --> | |
| 342 | 352 | ||
| 343 | 353 | * `response` {http.IncomingMessage} | |
| 344 | - * `socket` {net.Socket} | ||
| 354 | + * `socket` {stream.Duplex} | ||
| 345 | 355 | * `head` {Buffer} | |
| 346 | 356 | ||
| 347 | 357 | Emitted each time a server responds to a request with a `CONNECT` method. If | |
| 348 | 358 | this event is not being listened for, clients receiving a `CONNECT` method will | |
| 349 | 359 | have their connections closed. | |
| 350 | 360 | ||
| 361 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 362 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 363 | + type other than {net.Socket}. | ||
| 364 | + | ||
| 351 | 365 | A client and server pair demonstrating how to listen for the `'connect'` event: | |
| 352 | 366 | ||
| 353 | 367 | ```js | |
@@ -471,9 +485,11 @@ once. | |||
| 471 | 485 | added: v0.5.3 | |
| 472 | 486 | --> | |
| 473 | 487 | ||
| 474 | - * `socket` {net.Socket} | ||
| 488 | + * `socket` {stream.Duplex} | ||
| 475 | 489 | ||
| 476 | - Emitted after a socket is assigned to this request. | ||
| 490 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 491 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 492 | + type other than {net.Socket}. | ||
| 477 | 493 | ||
| 478 | 494 | ### Event: 'timeout' | |
| 479 | 495 | <!-- YAML | |
@@ -491,14 +507,18 @@ added: v0.1.94 | |||
| 491 | 507 | --> | |
| 492 | 508 | ||
| 493 | 509 | * `response` {http.IncomingMessage} | |
| 494 | - * `socket` {net.Socket} | ||
| 510 | + * `socket` {stream.Duplex} | ||
| 495 | 511 | * `head` {Buffer} | |
| 496 | 512 | ||
| 497 | 513 | Emitted each time a server responds to a request with an upgrade. If this | |
| 498 | 514 | event is not being listened for and the response status code is 101 Switching | |
| 499 | 515 | Protocols, clients receiving an upgrade header will have their connections | |
| 500 | 516 | closed. | |
| 501 | 517 | ||
| 518 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 519 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 520 | + type other than {net.Socket}. | ||
| 521 | + | ||
| 502 | 522 | A client server pair demonstrating how to listen for the `'upgrade'` event. | |
| 503 | 523 | ||
| 504 | 524 | ```js | |
@@ -572,7 +592,7 @@ deprecated: v13.0.0 | |||
| 572 | 592 | ||
| 573 | 593 | > Stability: 0 - Deprecated. Use [`request.socket`][]. | |
| 574 | 594 | ||
| 575 | - * {net.Socket} | ||
| 595 | + * {stream.Duplex} | ||
| 576 | 596 | ||
| 577 | 597 | See [`request.socket`][]. | |
| 578 | 598 | ||
@@ -800,7 +820,7 @@ Once a socket is assigned to this request and is connected | |||
| 800 | 820 | added: v0.3.0 | |
| 801 | 821 | --> | |
| 802 | 822 | ||
| 803 | - * {net.Socket} | ||
| 823 | + * {stream.Duplex} | ||
| 804 | 824 | ||
| 805 | 825 | Reference to the underlying socket. Usually users will not want to access | |
| 806 | 826 | this property. In particular, the socket will not emit `'readable'` events | |
@@ -822,6 +842,10 @@ req.once('response', (res) => { | |||
| 822 | 842 | }); | |
| 823 | 843 | ``` | |
| 824 | 844 | ||
| 845 | + This property is guaranteed to be an instance of the {net.Socket} class, | ||
| 846 | + a subclass of {stream.Duplex}, unless the user specified a socket | ||
| 847 | + type other than {net.Socket}. | ||
| 848 | + | ||
| 825 | 849 | ### request.writableEnded | |
| 826 | 850 | <!-- YAML | |
| 827 | 851 | added: v12.9.0 | |
@@ -935,13 +959,17 @@ changes: | |||
| 935 | 959 | --> | |
| 936 | 960 | ||
| 937 | 961 | * `exception` {Error} | |
| 938 | - * `socket` {net.Socket} | ||
| 962 | + * `socket` {stream.Duplex} | ||
| 939 | 963 | ||
| 940 | 964 | If a client connection emits an `'error'` event, it will be forwarded here. | |
| 941 | 965 | Listener of this event is responsible for closing/destroying the underlying | |
| 942 | 966 | socket. For example, one may wish to more gracefully close the socket with a | |
| 943 | 967 | custom HTTP response instead of abruptly severing the connection. | |
| 944 | 968 | ||
| 969 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 970 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 971 | + type other than {net.Socket}. | ||
| 972 | + | ||
| 945 | 973 | Default behavior is to try close the socket with a HTTP '400 Bad Request', | |
| 946 | 974 | or a HTTP '431 Request Header Fields Too Large' in the case of a | |
| 947 | 975 | [`HPE_HEADER_OVERFLOW`][] error. If the socket is not writable it is | |
@@ -986,13 +1014,17 @@ added: v0.7.0 | |||
| 986 | 1014 | ||
| 987 | 1015 | * `request` {http.IncomingMessage} Arguments for the HTTP request, as it is in | |
| 988 | 1016 | the [`'request'`][] event | |
| 989 | - * `socket` {net.Socket} Network socket between the server and client | ||
| 1017 | + * `socket` {stream.Duplex} Network socket between the server and client | ||
| 990 | 1018 | * `head` {Buffer} The first packet of the tunneling stream (may be empty) | |
| 991 | 1019 | ||
| 992 | 1020 | Emitted each time a client requests an HTTP `CONNECT` method. If this event is | |
| 993 | 1021 | not listened for, then clients requesting a `CONNECT` method will have their | |
| 994 | 1022 | connections closed. | |
| 995 | 1023 | ||
| 1024 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 1025 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 1026 | + type other than {net.Socket}. | ||
| 1027 | + | ||
| 996 | 1028 | After this event is emitted, the request's socket will not have a `'data'` | |
| 997 | 1029 | event listener, meaning it will need to be bound in order to handle data | |
| 998 | 1030 | sent to the server on that socket. | |
@@ -1002,7 +1034,7 @@ sent to the server on that socket. | |||
| 1002 | 1034 | added: v0.1.0 | |
| 1003 | 1035 | --> | |
| 1004 | 1036 | ||
| 1005 | - * `socket` {net.Socket} | ||
| 1037 | + * `socket` {stream.Duplex} | ||
| 1006 | 1038 | ||
| 1007 | 1039 | This event is emitted when a new TCP stream is established. `socket` is | |
| 1008 | 1040 | typically an object of type [`net.Socket`][]. Usually users will not want to | |
@@ -1017,6 +1049,10 @@ If `socket.setTimeout()` is called here, the timeout will be replaced with | |||
| 1017 | 1049 | `server.keepAliveTimeout` when the socket has served a request (if | |
| 1018 | 1050 | `server.keepAliveTimeout` is non-zero). | |
| 1019 | 1051 | ||
| 1052 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 1053 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 1054 | + type other than {net.Socket}. | ||
| 1055 | + | ||
| 1020 | 1056 | ### Event: 'request' | |
| 1021 | 1057 | <!-- YAML | |
| 1022 | 1058 | added: v0.1.0 | |
@@ -1040,7 +1076,7 @@ changes: | |||
| 1040 | 1076 | ||
| 1041 | 1077 | * `request` {http.IncomingMessage} Arguments for the HTTP request, as it is in | |
| 1042 | 1078 | the [`'request'`][] event | |
| 1043 | - * `socket` {net.Socket} Network socket between the server and client | ||
| 1079 | + * `socket` {stream.Duplex} Network socket between the server and client | ||
| 1044 | 1080 | * `head` {Buffer} The first packet of the upgraded stream (may be empty) | |
| 1045 | 1081 | ||
| 1046 | 1082 | Emitted each time a client requests an HTTP upgrade. Listening to this event | |
@@ -1050,6 +1086,10 @@ After this event is emitted, the request's socket will not have a `'data'` | |||
| 1050 | 1086 | event listener, meaning it will need to be bound in order to handle data | |
| 1051 | 1087 | sent to the server on that socket. | |
| 1052 | 1088 | ||
| 1089 | + This event is guaranteed to be passed an instance of the {net.Socket} class, | ||
| 1090 | + a subclass of {stream.Duplex}, unless the user specifies a socket | ||
| 1091 | + type other than {net.Socket}. | ||
| 1092 | + | ||
| 1053 | 1093 | ### server.close(\[callback\]) | |
| 1054 | 1094 | <!-- YAML | |
| 1055 | 1095 | added: v0.1.90 | |
@@ -1227,7 +1267,7 @@ deprecated: v13.0.0 | |||
| 1227 | 1267 | ||
| 1228 | 1268 | > Stability: 0 - Deprecated. Use [`response.socket`][]. | |
| 1229 | 1269 | ||
| 1230 | - * {net.Socket} | ||
| 1270 | + * {stream.Duplex} | ||
| 1231 | 1271 | ||
| 1232 | 1272 | See [`response.socket`][]. | |
| 1233 | 1273 | ||
@@ -1469,7 +1509,7 @@ timed out sockets must be handled explicitly. | |||
| 1469 | 1509 | added: v0.3.0 | |
| 1470 | 1510 | --> | |
| 1471 | 1511 | ||
| 1472 | - * {net.Socket} | ||
| 1512 | + * {stream.Duplex} | ||
| 1473 | 1513 | ||
| 1474 | 1514 | Reference to the underlying socket. Usually users will not want to access | |
| 1475 | 1515 | this property. In particular, the socket will not emit `'readable'` events | |
@@ -1486,6 +1526,10 @@ const server = http.createServer((req, res) => { | |||
| 1486 | 1526 | }).listen(3000); | |
| 1487 | 1527 | ``` | |
| 1488 | 1528 | ||
| 1529 | + This property is guaranteed to be an instance of the {net.Socket} class, | ||
| 1530 | + a subclass of {stream.Duplex}, unless the user specified a socket | ||
| 1531 | + type other than {net.Socket}. | ||
| 1532 | + | ||
| 1489 | 1533 | ### response.statusCode | |
| 1490 | 1534 | <!-- YAML | |
| 1491 | 1535 | added: v0.4.0 | |
@@ -1868,13 +1912,17 @@ Calls `message.connection.setTimeout(msecs, callback)`. | |||
| 1868 | 1912 | added: v0.3.0 | |
| 1869 | 1913 | --> | |
| 1870 | 1914 | ||
| 1871 | - * {net.Socket} | ||
| 1915 | + * {stream.Duplex} | ||
| 1872 | 1916 | ||
| 1873 | 1917 | The [`net.Socket`][] object associated with the connection. | |
| 1874 | 1918 | ||
| 1875 | 1919 | With HTTPS support, use [`request.socket.getPeerCertificate()`][] to obtain the | |
| 1876 | 1920 | client's authentication details. | |
| 1877 | 1921 | ||
| 1922 | + This property is guaranteed to be an instance of the {net.Socket} class, | ||
| 1923 | + a subclass of {stream.Duplex}, unless the user specified a socket | ||
| 1924 | + type other than {net.Socket}. | ||
| 1925 | + | ||
| 1878 | 1926 | ### message.statusCode | |
| 1879 | 1927 | <!-- YAML | |
| 1880 | 1928 | added: v0.1.1 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments