@@ -2049,7 +2049,7 @@ console.log(request.headers);
2049
2049
2050
2050
See [ Headers Object] [ ] .
2051
2051
2052
- ### request.httpVersion
2052
+ #### request.httpVersion
2053
2053
<!-- YAML
2054
2054
added: v8.4.0
2055
2055
-->
@@ -2120,7 +2120,14 @@ added: v8.4.0
2120
2120
* ` msecs ` {number}
2121
2121
* ` callback ` {Function}
2122
2122
2123
- Calls ` request.connection.setTimeout(msecs, callback) ` .
2123
+ Sets the [ ` Http2Stream ` ] ( ) 's timeout value to ` msecs ` . If a callback is
2124
+ provided, then it is added as a listener on the ` 'timeout' ` event on
2125
+ the response object.
2126
+
2127
+ If no ` 'timeout' ` listener is added to the request, the response, or
2128
+ the server, then [ ` Http2Stream ` ] ( ) s are destroyed when they time out. If a
2129
+ handler is assigned to the request, the response, or the server's ` 'timeout' `
2130
+ events, timed out sockets must be handled explicitly.
2124
2131
2125
2132
Returns ` request ` .
2126
2133
@@ -2131,13 +2138,24 @@ added: v8.4.0
2131
2138
2132
2139
* {net.Socket}
2133
2140
2134
- The [ ` net.Socket ` ] [ ] object associated with the connection.
2141
+ Returns a Proxy object that acts as a ` net.Socket ` but applies getters,
2142
+ setters and methods based on HTTP/2 logic.
2143
+
2144
+ ` destroyed ` , ` readable ` , and ` writable ` properties will be retrieved from and
2145
+ set on ` request.stream ` .
2135
2146
2136
- With TLS support, use [ ` request.socket.getPeerCertificate() ` ] [ ] to obtain the
2137
- client's authentication details .
2147
+ ` destroy ` , ` emit ` , ` end ` , ` on ` and ` once ` methods will be called on
2148
+ ` request.stream ` .
2138
2149
2139
- * Note* : do not use this socket object to send or receive any data. All
2140
- data transfers are managed by HTTP/2 and data might be lost.
2150
+ ` setTimeout ` method will be called on ` request.stream.session ` .
2151
+
2152
+ ` pause ` , ` read ` , ` resume ` , and ` write ` will throw an error with code
2153
+ ` ERR_HTTP2_NO_SOCKET_MANIPULATION ` . See [ ` Http2Session and Sockets ` ] [ ] for
2154
+ more information.
2155
+
2156
+ All other interactions will be routed directly to the socket. With TLS support,
2157
+ use [ ` request.socket.getPeerCertificate() ` ] [ ] to obtain the client's
2158
+ authentication details.
2141
2159
2142
2160
#### request.stream
2143
2161
<!-- YAML
@@ -2235,15 +2253,15 @@ passed as the second parameter to the [`'request'`][] event.
2235
2253
The response implements, but does not inherit from, the [ Writable Stream] [ ]
2236
2254
interface. This is an [ ` EventEmitter ` ] [ ] with the following events:
2237
2255
2238
- ### Event: 'close'
2256
+ #### Event: 'close'
2239
2257
<!-- YAML
2240
2258
added: v8.4.0
2241
2259
-->
2242
2260
2243
2261
Indicates that the underlying [ ` Http2Stream ` ] ( ) was terminated before
2244
2262
[ ` response.end() ` ] [ ] was called or able to flush.
2245
2263
2246
- ### Event: 'finish'
2264
+ #### Event: 'finish'
2247
2265
<!-- YAML
2248
2266
added: v8.4.0
2249
2267
-->
@@ -2255,7 +2273,7 @@ does not imply that the client has received anything yet.
2255
2273
2256
2274
After this event, no more events will be emitted on the response object.
2257
2275
2258
- ### response.addTrailers(headers)
2276
+ #### response.addTrailers(headers)
2259
2277
<!-- YAML
2260
2278
added: v8.4.0
2261
2279
-->
@@ -2268,7 +2286,7 @@ message) to the response.
2268
2286
Attempting to set a header field name or value that contains invalid characters
2269
2287
will result in a [ ` TypeError ` ] [ ] being thrown.
2270
2288
2271
- ### response.connection
2289
+ #### response.connection
2272
2290
<!-- YAML
2273
2291
added: v8.4.0
2274
2292
-->
@@ -2277,7 +2295,7 @@ added: v8.4.0
2277
2295
2278
2296
See [ ` response.socket ` ] [ ] .
2279
2297
2280
- ### response.end([ data] [ , encoding ] [ , callback] )
2298
+ #### response.end([ data] [ , encoding ] [ , callback] )
2281
2299
<!-- YAML
2282
2300
added: v8.4.0
2283
2301
-->
@@ -2296,7 +2314,7 @@ If `data` is specified, it is equivalent to calling
2296
2314
If ` callback ` is specified, it will be called when the response stream
2297
2315
is finished.
2298
2316
2299
- ### response.finished
2317
+ #### response.finished
2300
2318
<!-- YAML
2301
2319
added: v8.4.0
2302
2320
-->
@@ -2306,7 +2324,7 @@ added: v8.4.0
2306
2324
Boolean value that indicates whether the response has completed. Starts
2307
2325
as ` false ` . After [ ` response.end() ` ] [ ] executes, the value will be ` true ` .
2308
2326
2309
- ### response.getHeader(name)
2327
+ #### response.getHeader(name)
2310
2328
<!-- YAML
2311
2329
added: v8.4.0
2312
2330
-->
@@ -2323,7 +2341,7 @@ Example:
2323
2341
const contentType = response .getHeader (' content-type' );
2324
2342
```
2325
2343
2326
- ### response.getHeaderNames()
2344
+ #### response.getHeaderNames()
2327
2345
<!-- YAML
2328
2346
added: v8.4.0
2329
2347
-->
@@ -2343,7 +2361,7 @@ const headerNames = response.getHeaderNames();
2343
2361
// headerNames === ['foo', 'set-cookie']
2344
2362
```
2345
2363
2346
- ### response.getHeaders()
2364
+ #### response.getHeaders()
2347
2365
<!-- YAML
2348
2366
added: v8.4.0
2349
2367
-->
@@ -2371,7 +2389,7 @@ const headers = response.getHeaders();
2371
2389
// headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
2372
2390
```
2373
2391
2374
- ### response.hasHeader(name)
2392
+ #### response.hasHeader(name)
2375
2393
<!-- YAML
2376
2394
added: v8.4.0
2377
2395
-->
@@ -2388,7 +2406,7 @@ Example:
2388
2406
const hasContentType = response .hasHeader (' content-type' );
2389
2407
```
2390
2408
2391
- ### response.headersSent
2409
+ #### response.headersSent
2392
2410
<!-- YAML
2393
2411
added: v8.4.0
2394
2412
-->
@@ -2397,7 +2415,7 @@ added: v8.4.0
2397
2415
2398
2416
Boolean (read-only). True if headers were sent, false otherwise.
2399
2417
2400
- ### response.removeHeader(name)
2418
+ #### response.removeHeader(name)
2401
2419
<!-- YAML
2402
2420
added: v8.4.0
2403
2421
-->
@@ -2412,7 +2430,7 @@ Example:
2412
2430
response .removeHeader (' Content-Encoding' );
2413
2431
```
2414
2432
2415
- ### response.sendDate
2433
+ #### response.sendDate
2416
2434
<!-- YAML
2417
2435
added: v8.4.0
2418
2436
-->
@@ -2425,7 +2443,7 @@ the response if it is not already present in the headers. Defaults to true.
2425
2443
This should only be disabled for testing; HTTP requires the Date header
2426
2444
in responses.
2427
2445
2428
- ### response.setHeader(name, value)
2446
+ #### response.setHeader(name, value)
2429
2447
<!-- YAML
2430
2448
added: v8.4.0
2431
2449
-->
@@ -2466,7 +2484,7 @@ const server = http2.createServer((req, res) => {
2466
2484
});
2467
2485
```
2468
2486
2469
- ### response.setTimeout(msecs[ , callback] )
2487
+ #### response.setTimeout(msecs[ , callback] )
2470
2488
<!-- YAML
2471
2489
added: v8.4.0
2472
2490
-->
@@ -2485,18 +2503,29 @@ events, timed out sockets must be handled explicitly.
2485
2503
2486
2504
Returns ` response ` .
2487
2505
2488
- ### response.socket
2506
+ #### response.socket
2489
2507
<!-- YAML
2490
2508
added: v8.4.0
2491
2509
-->
2492
2510
2493
2511
* {net.Socket}
2494
2512
2495
- Reference to the underlying socket. Usually users will not want to access
2496
- this property. In particular, the socket will not emit ` 'readable' ` events
2497
- because of how the protocol parser attaches to the socket. After
2498
- ` response.end() ` , the property is nulled. The ` socket ` may also be accessed
2499
- via ` response.connection ` .
2513
+ Returns a Proxy object that acts as a ` net.Socket ` but applies getters,
2514
+ setters and methods based on HTTP/2 logic.
2515
+
2516
+ ` destroyed ` , ` readable ` , and ` writable ` properties will be retrieved from and
2517
+ set on ` response.stream ` .
2518
+
2519
+ ` destroy ` , ` emit ` , ` end ` , ` on ` and ` once ` methods will be called on
2520
+ ` response.stream ` .
2521
+
2522
+ ` setTimeout ` method will be called on ` response.stream.session ` .
2523
+
2524
+ ` pause ` , ` read ` , ` resume ` , and ` write ` will throw an error with code
2525
+ ` ERR_HTTP2_NO_SOCKET_MANIPULATION ` . See [ ` Http2Session and Sockets ` ] [ ] for
2526
+ more information.
2527
+
2528
+ All other interactions will be routed directly to the socket.
2500
2529
2501
2530
Example:
2502
2531
@@ -2509,7 +2538,7 @@ const server = http2.createServer((req, res) => {
2509
2538
}).listen (3000 );
2510
2539
```
2511
2540
2512
- ### response.statusCode
2541
+ #### response.statusCode
2513
2542
<!-- YAML
2514
2543
added: v8.4.0
2515
2544
-->
@@ -2529,7 +2558,7 @@ response.statusCode = 404;
2529
2558
After response header was sent to the client, this property indicates the
2530
2559
status code which was sent out.
2531
2560
2532
- ### response.statusMessage
2561
+ #### response.statusMessage
2533
2562
<!-- YAML
2534
2563
added: v8.4.0
2535
2564
-->
@@ -2548,7 +2577,7 @@ added: v8.4.0
2548
2577
2549
2578
The [ ` Http2Stream ` ] [ ] object backing the response.
2550
2579
2551
- ### response.write(chunk[ , encoding] [ , callback ] )
2580
+ #### response.write(chunk[ , encoding] [ , callback ] )
2552
2581
<!-- YAML
2553
2582
added: v8.4.0
2554
2583
-->
@@ -2586,7 +2615,7 @@ Returns `true` if the entire data was flushed successfully to the kernel
2586
2615
buffer. Returns ` false ` if all or part of the data was queued in user memory.
2587
2616
` 'drain' ` will be emitted when the buffer is free again.
2588
2617
2589
- ### response.writeContinue()
2618
+ #### response.writeContinue()
2590
2619
<!-- YAML
2591
2620
added: v8.4.0
2592
2621
-->
@@ -2595,7 +2624,7 @@ Sends a status `100 Continue` to the client, indicating that the request body
2595
2624
should be sent. See the [ ` 'checkContinue' ` ] [ ] event on ` Http2Server ` and
2596
2625
` Http2SecureServer ` .
2597
2626
2598
- ### response.writeHead(statusCode[ , statusMessage] [ , headers ] )
2627
+ #### response.writeHead(statusCode[ , statusMessage] [ , headers ] )
2599
2628
<!-- YAML
2600
2629
added: v8.4.0
2601
2630
-->
@@ -2651,7 +2680,7 @@ const server = http2.createServer((req, res) => {
2651
2680
Attempting to set a header field name or value that contains invalid characters
2652
2681
will result in a [ ` TypeError ` ] [ ] being thrown.
2653
2682
2654
- ### response.createPushResponse(headers, callback)
2683
+ #### response.createPushResponse(headers, callback)
2655
2684
<!-- YAML
2656
2685
added: v8.4.0
2657
2686
-->
0 commit comments