| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7f457f8 commit b7ea39d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -760,7 +760,7 @@ const deprecateWeight = deprecateProperty('weight', | |||
| 760 | 760 | // When a ClientHttp2Session is first created, the socket may not yet be | |
| 761 | 761 | // connected. If request() is called during this time, the actual request | |
| 762 | 762 | // will be deferred until the socket is ready to go. | |
| 763 | - function requestOnConnect(headersList, headersParam, options) { | ||
| 763 | + function requestOnConnect(headersList, options) { | ||
| 764 | 764 | const session = this[kSession]; | |
| 765 | 765 | ||
| 766 | 766 | // At this point, the stream should have already been destroyed during | |
@@ -824,7 +824,7 @@ function requestOnConnect(headersList, headersParam, options) { | |||
| 824 | 824 | if (onClientStreamStartChannel.hasSubscribers) { | |
| 825 | 825 | onClientStreamStartChannel.publish({ | |
| 826 | 826 | stream: this, | |
| 827 | - headers: headersParam, | ||
| 827 | + headers: this.sentHeaders, | ||
| 828 | 828 | }); | |
| 829 | 829 | } | |
| 830 | 830 | } | |
@@ -1888,7 +1888,7 @@ class ClientHttp2Session extends Http2Session { | |||
| 1888 | 1888 | } | |
| 1889 | 1889 | } | |
| 1890 | 1890 | ||
| 1891 | - const onConnect = reqAsync.bind(requestOnConnect.bind(stream, headersList, headersParam, options)); | ||
| 1891 | + const onConnect = reqAsync.bind(requestOnConnect.bind(stream, headersList, options)); | ||
| 1892 | 1892 | if (this.connecting) { | |
| 1893 | 1893 | if (this[kPendingRequestCalls] !== null) { | |
| 1894 | 1894 | this[kPendingRequestCalls].push(onConnect); | |
@@ -1906,7 +1906,7 @@ class ClientHttp2Session extends Http2Session { | |||
| 1906 | 1906 | if (onClientStreamCreatedChannel.hasSubscribers) { | |
| 1907 | 1907 | onClientStreamCreatedChannel.publish({ | |
| 1908 | 1908 | stream, | |
| 1909 | - headers: headersParam, | ||
| 1909 | + headers: stream.sentHeaders, | ||
| 1910 | 1910 | }); | |
| 1911 | 1911 | } | |
| 1912 | 1912 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,36 +18,61 @@ const { Duplex } = require('stream'); | |||
| 18 | 18 | ||
| 19 | 19 | const clientHttp2StreamCreationCount = 2; | |
| 20 | 20 | ||
| 21 | + let countdown; | ||
| 22 | + let port; | ||
| 23 | + | ||
| 21 | 24 | dc.subscribe('http2.client.stream.created', common.mustCall(({ stream, headers }) => { | |
| 22 | 25 | // Since ClientHttp2Stream is not exported from any module, this just checks | |
| 23 | 26 | // if the stream is an instance of Duplex and the constructor name is | |
| 24 | 27 | // 'ClientHttp2Stream'. | |
| 25 | 28 | assert.ok(stream instanceof Duplex); | |
| 26 | 29 | assert.strictEqual(stream.constructor.name, 'ClientHttp2Stream'); | |
| 27 | 30 | assert.ok(headers && !Array.isArray(headers) && typeof headers === 'object'); | |
| 31 | + if (countdown.remaining === clientHttp2StreamCreationCount) { | ||
| 32 | + // The request stream headers. | ||
| 33 | + assert.deepStrictEqual(headers, { | ||
| 34 | + '__proto__': null, | ||
| 35 | + ':method': 'GET', | ||
| 36 | + ':authority': `localhost:${port}`, | ||
| 37 | + ':scheme': 'http', | ||
| 38 | + ':path': '/', | ||
| 39 | + 'requestHeader': 'requestValue', | ||
| 40 | + }); | ||
| 41 | + } else { | ||
| 42 | + // The push stream headers. | ||
| 43 | + assert.deepStrictEqual(headers, { | ||
| 44 | + '__proto__': null, | ||
| 45 | + ':method': 'GET', | ||
| 46 | + ':authority': `localhost:${port}`, | ||
| 47 | + ':scheme': 'http', | ||
| 48 | + ':path': '/', | ||
| 49 | + [http2.sensitiveHeaders]: [], | ||
| 50 | + 'pushheader': 'pushValue', | ||
| 51 | + }); | ||
| 52 | + } | ||
| 28 | 53 | }, clientHttp2StreamCreationCount)); | |
| 29 | 54 | ||
| 30 | 55 | const server = http2.createServer(); | |
| 31 | 56 | server.on('stream', common.mustCall((stream) => { | |
| 32 | 57 | stream.respond(); | |
| 33 | 58 | stream.end(); | |
| 34 | 59 | ||
| 35 | - stream.pushStream({}, common.mustSucceed((pushStream) => { | ||
| 60 | + stream.pushStream({ 'pushHeader': 'pushValue' }, common.mustSucceed((pushStream) => { | ||
| 36 | 61 | pushStream.respond(); | |
| 37 | 62 | pushStream.end(); | |
| 38 | 63 | }, 1)); | |
| 39 | 64 | }, 1)); | |
| 40 | 65 | ||
| 41 | 66 | server.listen(0, common.mustCall(() => { | |
| 42 | - const port = server.address().port; | ||
| 67 | + port = server.address().port; | ||
| 43 | 68 | const client = http2.connect(`http://localhost:${port}`); | |
| 44 | 69 | ||
| 45 | - const countdown = new Countdown(clientHttp2StreamCreationCount, () => { | ||
| 70 | + countdown = new Countdown(clientHttp2StreamCreationCount, () => { | ||
| 46 | 71 | client.close(); | |
| 47 | 72 | server.close(); | |
| 48 | 73 | }); | |
| 49 | 74 | ||
| 50 | - const stream = client.request({}); | ||
| 75 | + const stream = client.request(['requestHeader', 'requestValue']); | ||
| 51 | 76 | stream.on('response', common.mustCall(() => { | |
| 52 | 77 | countdown.dec(); | |
| 53 | 78 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,35 +18,61 @@ const { Duplex } = require('stream'); | |||
| 18 | 18 | ||
| 19 | 19 | const clientHttp2StreamStartCount = 2; | |
| 20 | 20 | ||
| 21 | + let countdown; | ||
| 22 | + let port; | ||
| 23 | + | ||
| 21 | 24 | dc.subscribe('http2.client.stream.start', common.mustCall(({ stream, headers }) => { | |
| 22 | 25 | // Since ClientHttp2Stream is not exported from any module, this just checks | |
| 23 | 26 | // if the stream is an instance of Duplex. | |
| 24 | 27 | assert.ok(stream instanceof Duplex); | |
| 25 | 28 | assert.strictEqual(stream.constructor.name, 'ClientHttp2Stream'); | |
| 26 | 29 | assert.ok(headers && !Array.isArray(headers) && typeof headers === 'object'); | |
| 30 | + | ||
| 31 | + if (countdown.remaining === clientHttp2StreamStartCount) { | ||
| 32 | + // The request stream headers. | ||
| 33 | + assert.deepStrictEqual(headers, { | ||
| 34 | + '__proto__': null, | ||
| 35 | + ':method': 'GET', | ||
| 36 | + ':authority': `localhost:${port}`, | ||
| 37 | + ':scheme': 'http', | ||
| 38 | + ':path': '/', | ||
| 39 | + 'requestHeader': 'requestValue', | ||
| 40 | + }); | ||
| 41 | + } else { | ||
| 42 | + // The push stream headers. | ||
| 43 | + assert.deepStrictEqual(headers, { | ||
| 44 | + '__proto__': null, | ||
| 45 | + ':method': 'GET', | ||
| 46 | + ':authority': `localhost:${port}`, | ||
| 47 | + ':scheme': 'http', | ||
| 48 | + ':path': '/', | ||
| 49 | + [http2.sensitiveHeaders]: [], | ||
| 50 | + 'pushheader': 'pushValue', | ||
| 51 | + }); | ||
| 52 | + } | ||
| 27 | 53 | }, clientHttp2StreamStartCount)); | |
| 28 | 54 | ||
| 29 | 55 | const server = http2.createServer(); | |
| 30 | 56 | server.on('stream', common.mustCall((stream) => { | |
| 31 | 57 | stream.respond(); | |
| 32 | 58 | stream.end(); | |
| 33 | 59 | ||
| 34 | - stream.pushStream({}, common.mustSucceed((pushStream) => { | ||
| 60 | + stream.pushStream({ 'pushHeader': 'pushValue' }, common.mustSucceed((pushStream) => { | ||
| 35 | 61 | pushStream.respond(); | |
| 36 | 62 | pushStream.end(); | |
| 37 | 63 | }, 1)); | |
| 38 | 64 | }, 1)); | |
| 39 | 65 | ||
| 40 | 66 | server.listen(0, common.mustCall(() => { | |
| 41 | - const port = server.address().port; | ||
| 67 | + port = server.address().port; | ||
| 42 | 68 | const client = http2.connect(`http://localhost:${port}`); | |
| 43 | 69 | ||
| 44 | - const countdown = new Countdown(clientHttp2StreamStartCount, () => { | ||
| 70 | + countdown = new Countdown(clientHttp2StreamStartCount, () => { | ||
| 45 | 71 | client.close(); | |
| 46 | 72 | server.close(); | |
| 47 | 73 | }); | |
| 48 | 74 | ||
| 49 | - const stream = client.request({}); | ||
| 75 | + const stream = client.request(['requestHeader', 'requestValue']); | ||
| 50 | 76 | stream.on('response', common.mustCall(() => { | |
| 51 | 77 | countdown.dec(); | |
| 52 | 78 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments