@@ -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
@@ -569,7 +589,7 @@ been aborted.
569
589
added: v0.3.0
570
590
-->
571
591
572
- * {net.Socket }
592
+ * {stream.Duplex }
573
593
574
594
See [ ` request.socket ` ] [ ] .
575
595
@@ -797,7 +817,7 @@ Once a socket is assigned to this request and is connected
797
817
added: v0.3.0
798
818
-->
799
819
800
- * {net.Socket }
820
+ * {stream.Duplex }
801
821
802
822
Reference to the underlying socket. Usually users will not want to access
803
823
this property. In particular, the socket will not emit ` 'readable' ` events
@@ -819,6 +839,10 @@ req.once('response', (res) => {
819
839
});
820
840
```
821
841
842
+ This property is guaranteed to be an instance of the {net.Socket} class,
843
+ a subclass of {stream.Duplex}, unless the user specified a socket
844
+ type other than {net.Socket}.
845
+
822
846
### ` request.writableEnded `
823
847
<!-- YAML
824
848
added: v12.9.0
@@ -932,13 +956,17 @@ changes:
932
956
-->
933
957
934
958
* ` exception ` {Error}
935
- * ` socket ` {net.Socket }
959
+ * ` socket ` {stream.Duplex }
936
960
937
961
If a client connection emits an ` 'error' ` event, it will be forwarded here.
938
962
Listener of this event is responsible for closing/destroying the underlying
939
963
socket. For example, one may wish to more gracefully close the socket with a
940
964
custom HTTP response instead of abruptly severing the connection.
941
965
966
+ This event is guaranteed to be passed an instance of the {net.Socket} class,
967
+ a subclass of {stream.Duplex}, unless the user specifies a socket
968
+ type other than {net.Socket}.
969
+
942
970
Default behavior is to try close the socket with a HTTP '400 Bad Request',
943
971
or a HTTP '431 Request Header Fields Too Large' in the case of a
944
972
[ ` HPE_HEADER_OVERFLOW ` ] [ ] error. If the socket is not writable it is
@@ -983,13 +1011,17 @@ added: v0.7.0
983
1011
984
1012
* ` request ` {http.IncomingMessage} Arguments for the HTTP request, as it is in
985
1013
the [ ` 'request' ` ] [ ] event
986
- * ` socket ` {net.Socket } Network socket between the server and client
1014
+ * ` socket ` {stream.Duplex } Network socket between the server and client
987
1015
* ` head ` {Buffer} The first packet of the tunneling stream (may be empty)
988
1016
989
1017
Emitted each time a client requests an HTTP ` CONNECT ` method. If this event is
990
1018
not listened for, then clients requesting a ` CONNECT ` method will have their
991
1019
connections closed.
992
1020
1021
+ This event is guaranteed to be passed an instance of the {net.Socket} class,
1022
+ a subclass of {stream.Duplex}, unless the user specifies a socket
1023
+ type other than {net.Socket}.
1024
+
993
1025
After this event is emitted, the request's socket will not have a ` 'data' `
994
1026
event listener, meaning it will need to be bound in order to handle data
995
1027
sent to the server on that socket.
@@ -999,7 +1031,7 @@ sent to the server on that socket.
999
1031
added: v0.1.0
1000
1032
-->
1001
1033
1002
- * ` socket ` {net.Socket }
1034
+ * ` socket ` {stream.Duplex }
1003
1035
1004
1036
This event is emitted when a new TCP stream is established. ` socket ` is
1005
1037
typically an object of type [ ` net.Socket ` ] [ ] . Usually users will not want to
@@ -1014,6 +1046,10 @@ If `socket.setTimeout()` is called here, the timeout will be replaced with
1014
1046
` server.keepAliveTimeout ` when the socket has served a request (if
1015
1047
` server.keepAliveTimeout ` is non-zero).
1016
1048
1049
+ This event is guaranteed to be passed an instance of the {net.Socket} class,
1050
+ a subclass of {stream.Duplex}, unless the user specifies a socket
1051
+ type other than {net.Socket}.
1052
+
1017
1053
### Event: ` 'request' `
1018
1054
<!-- YAML
1019
1055
added: v0.1.0
@@ -1037,7 +1073,7 @@ changes:
1037
1073
1038
1074
* ` request ` {http.IncomingMessage} Arguments for the HTTP request, as it is in
1039
1075
the [ ` 'request' ` ] [ ] event
1040
- * ` socket ` {net.Socket } Network socket between the server and client
1076
+ * ` socket ` {stream.Duplex } Network socket between the server and client
1041
1077
* ` head ` {Buffer} The first packet of the upgraded stream (may be empty)
1042
1078
1043
1079
Emitted each time a client requests an HTTP upgrade. Listening to this event
@@ -1047,6 +1083,10 @@ After this event is emitted, the request's socket will not have a `'data'`
1047
1083
event listener, meaning it will need to be bound in order to handle data
1048
1084
sent to the server on that socket.
1049
1085
1086
+ This event is guaranteed to be passed an instance of the {net.Socket} class,
1087
+ a subclass of {stream.Duplex}, unless the user specifies a socket
1088
+ type other than {net.Socket}.
1089
+
1050
1090
### ` server.close([callback]) `
1051
1091
<!-- YAML
1052
1092
added: v0.1.90
@@ -1219,7 +1259,7 @@ will result in a [`TypeError`][] being thrown.
1219
1259
added: v0.3.0
1220
1260
-->
1221
1261
1222
- * {net.Socket }
1262
+ * {stream.Duplex }
1223
1263
1224
1264
See [ ` response.socket ` ] [ ] .
1225
1265
@@ -1461,7 +1501,7 @@ timed out sockets must be handled explicitly.
1461
1501
added: v0.3.0
1462
1502
-->
1463
1503
1464
- * {net.Socket }
1504
+ * {stream.Duplex }
1465
1505
1466
1506
Reference to the underlying socket. Usually users will not want to access
1467
1507
this property. In particular, the socket will not emit ` 'readable' ` events
@@ -1478,6 +1518,10 @@ const server = http.createServer((req, res) => {
1478
1518
}).listen (3000 );
1479
1519
```
1480
1520
1521
+ This property is guaranteed to be an instance of the {net.Socket} class,
1522
+ a subclass of {stream.Duplex}, unless the user specified a socket
1523
+ type other than {net.Socket}.
1524
+
1481
1525
### ` response.statusCode `
1482
1526
<!-- YAML
1483
1527
added: v0.4.0
@@ -1860,13 +1904,17 @@ Calls `message.connection.setTimeout(msecs, callback)`.
1860
1904
added: v0.3.0
1861
1905
-->
1862
1906
1863
- * {net.Socket }
1907
+ * {stream.Duplex }
1864
1908
1865
1909
The [ ` net.Socket ` ] [ ] object associated with the connection.
1866
1910
1867
1911
With HTTPS support, use [ ` request.socket.getPeerCertificate() ` ] [ ] to obtain the
1868
1912
client's authentication details.
1869
1913
1914
+ This property is guaranteed to be an instance of the {net.Socket} class,
1915
+ a subclass of {stream.Duplex}, unless the user specified a socket
1916
+ type other than {net.Socket}.
1917
+
1870
1918
### ` message.statusCode `
1871
1919
<!-- YAML
1872
1920
added: v0.1.1
0 commit comments