| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -939,6 +939,12 @@ For HTTP/2 Client `Http2Session` instances only, the `http2session.request()` | |||
| 939 | 939 | creates and returns an `Http2Stream` instance that can be used to send an | |
| 940 | 940 | HTTP/2 request to the connected server. | |
| 941 | 941 | ||
| 942 | + When a `ClientHttp2Session` is first created, the socket may not yet be | ||
| 943 | + connected. if `clienthttp2session.request()` is called during this time, the | ||
| 944 | + actual request will be deferred until the socket is ready to go. | ||
| 945 | + If the `session` is closed before the actual request be executed, an | ||
| 946 | + `ERR_HTTP2_GOAWAY_SESSION` is thrown. | ||
| 947 | + | ||
| 942 | 948 | This method is only available if `http2session.type` is equal to | |
| 943 | 949 | `http2.constants.NGHTTP2_SESSION_CLIENT`. | |
| 944 | 950 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + if (!common.hasCrypto) | ||
| 5 | + common.skip('missing crypto'); | ||
| 6 | + | ||
| 7 | + const http2 = require('http2'); | ||
| 8 | + | ||
| 9 | + const server = http2.createServer(); | ||
| 10 | + | ||
| 11 | + server.listen(0, () => { | ||
| 12 | + const client = http2.connect(`http://localhost:${server.address().port}`); | ||
| 13 | + client.on('close', common.mustCall(() => { | ||
| 14 | + server.close(); | ||
| 15 | + })); | ||
| 16 | + | ||
| 17 | + // The client.close() is executed before the socket is able to make request | ||
| 18 | + const stream = client.request(); | ||
| 19 | + stream.on('error', common.expectsError({ code: 'ERR_HTTP2_GOAWAY_SESSION' })); | ||
| 20 | + | ||
| 21 | + setImmediate(() => client.close()); | ||
| 22 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments