@@ -496,6 +496,15 @@ added: v0.11.14
496
496
If a request has been aborted, this value is the time when the request was
497
497
aborted, in milliseconds since 1 January 1970 00:00:00 UTC.
498
498
499
+ ### request.connection
500
+ <!-- YAML
501
+ added: v0.3.0
502
+ -->
503
+
504
+ * {net.Socket}
505
+
506
+ See [ ` request.socket ` ] [ ]
507
+
499
508
### request.end([ data[ , encoding]] [ , callback ] )
500
509
<!-- YAML
501
510
added: v0.1.90
@@ -564,6 +573,30 @@ Once a socket is assigned to this request and is connected
564
573
565
574
Returns ` request ` .
566
575
576
+ ### request.socket
577
+ <!-- YAML
578
+ added: v0.3.0
579
+ -->
580
+
581
+ * {net.Socket}
582
+
583
+ Reference to the underlying socket. Usually users will not want to access
584
+ this property. In particular, the socket will not emit ` 'readable' ` events
585
+ because of how the protocol parser attaches to the socket. After
586
+ ` response.end() ` , the property is nulled. The ` socket ` may also be accessed
587
+ via ` request.connection ` .
588
+
589
+ Example:
590
+
591
+ ``` js
592
+ const http = require (' http' );
593
+ const server = http .createServer ((req , res ) => {
594
+ const ip = req .socket .remoteAddress ;
595
+ const port = req .socket .remotePort ;
596
+ res .end (` Your IP address is ${ ip} and your source port is ${ port} .` );
597
+ }).listen (3000 );
598
+ ```
599
+
567
600
### request.write(chunk[ , encoding] [ , callback ] )
568
601
<!-- YAML
569
602
added: v0.1.29
@@ -955,6 +988,16 @@ response.end();
955
988
Attempting to set a header field name or value that contains invalid characters
956
989
will result in a [ ` TypeError ` ] [ ] being thrown.
957
990
991
+
992
+ ### response.connection
993
+ <!-- YAML
994
+ added: v0.3.0
995
+ -->
996
+
997
+ * {net.Socket}
998
+
999
+ See [ ` response.socket ` ] [ ] .
1000
+
958
1001
### response.end([ data] [ , encoding ] [ , callback] )
959
1002
<!-- YAML
960
1003
added: v0.1.90
@@ -1163,6 +1206,30 @@ timed out sockets must be handled explicitly.
1163
1206
1164
1207
Returns ` response ` .
1165
1208
1209
+ ### response.socket
1210
+ <!-- YAML
1211
+ added: v0.3.0
1212
+ -->
1213
+
1214
+ * {net.Socket}
1215
+
1216
+ Reference to the underlying socket. Usually users will not want to access
1217
+ this property. In particular, the socket will not emit ` 'readable' ` events
1218
+ because of how the protocol parser attaches to the socket. After
1219
+ ` response.end() ` , the property is nulled. The ` socket ` may also be accessed
1220
+ via ` response.connection ` .
1221
+
1222
+ Example:
1223
+
1224
+ ``` js
1225
+ const http = require (' http' );
1226
+ const server = http .createServer ((req , res ) => {
1227
+ const ip = req .socket .remoteAddress ;
1228
+ const port = req .socket .remotePort ;
1229
+ res .end (` Your IP address is ${ ip} and your source port is ${ port} .` );
1230
+ }).listen (3000 );
1231
+ ```
1232
+
1166
1233
### response.statusCode
1167
1234
<!-- YAML
1168
1235
added: v0.4.0
@@ -1831,9 +1898,11 @@ const req = http.request(options, (res) => {
1831
1898
[ `net.Server` ] : net.html#net_class_net_server
1832
1899
[ `net.Socket` ] : net.html#net_class_net_socket
1833
1900
[ `net.createConnection()` ] : net.html#net_net_createconnection_options_connectlistener
1901
+ [ `request.socket` ] : #http_request_socket
1834
1902
[ `request.socket.getPeerCertificate()` ] : tls.html#tls_tlssocket_getpeercertificate_detailed
1835
1903
[ `response.end()` ] : #http_response_end_data_encoding_callback
1836
1904
[ `response.setHeader()` ] : #http_response_setheader_name_value
1905
+ [ `response.socket` ] : #http_response_socket
1837
1906
[ `response.write()` ] : #http_response_write_chunk_encoding_callback
1838
1907
[ `response.write(data, encoding)` ] : #http_response_write_chunk_encoding_callback
1839
1908
[ `response.writeContinue()` ] : #http_response_writecontinue
0 commit comments