Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit cc36461

Browse files
chakrabotboingoing
authored andcommitted
meta: merge node/master into node-chakracore/master
Merge b396c4d as of 2018-01-06 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Taylor Woll <tawoll@ntdev.microsoft.com>
2 parents 9790e12 + b396c4d commit cc36461

22 files changed

+324
-61
lines changed

doc/api/http2.md

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ When invoked, the handler function will receive three arguments:
166166

167167
If the `'frameError'` event is associated with a stream, the stream will be
168168
closed and destroyed immediately following the `'frameError'` event. If the
169-
event is not associated with a stream, the `Http2Session` will be shutdown
169+
event is not associated with a stream, the `Http2Session` will be shut down
170170
immediately following the `'frameError'` event.
171171

172172
#### Event: 'goaway'
@@ -183,7 +183,7 @@ the handler function will receive three arguments:
183183
* `opaqueData` {Buffer} If additional opaque data was included in the GOAWAY
184184
frame, a `Buffer` instance will be passed containing that data.
185185

186-
*Note*: The `Http2Session` instance will be shutdown automatically when the
186+
*Note*: The `Http2Session` instance will be shut down automatically when the
187187
`'goaway'` event is emitted.
188188

189189
#### Event: 'localSettings'
@@ -499,7 +499,7 @@ added: v8.4.0
499499
has been completed.
500500
* Returns: {undefined}
501501

502-
Attempts to shutdown this `Http2Session` using HTTP/2 defined procedures.
502+
Attempts to shut down this `Http2Session` using HTTP/2 defined procedures.
503503
If specified, the given `callback` function will be invoked once the shutdown
504504
process has completed.
505505

@@ -635,7 +635,7 @@ may be passed to clear any previously set alternative service for a given
635635
domain.
636636

637637
When a string is passed for the `originOrStream` argument, it will be parsed as
638-
a URL and the origin will be derived. For insetance, the origin for the
638+
a URL and the origin will be derived. For instance, the origin for the
639639
HTTP URL `'https://example.org/foo/bar'` is the ASCII string
640640
`'https://example.org'`. An error will be thrown if either the given string
641641
cannot be parsed as a URL or if a valid origin cannot be derived.
@@ -739,15 +739,15 @@ req.on('response', (headers) => {
739739

740740
When set, the `options.getTrailers()` function is called immediately after
741741
queuing the last chunk of payload data to be sent. The callback is passed a
742-
single object (with a `null` prototype) that the listener may used to specify
742+
single object (with a `null` prototype) that the listener may use to specify
743743
the trailing header fields to send to the peer.
744744

745745
*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2
746-
"pseudo-header" fields (e.g. `':method'`, `':path'`, etc). An `'error'` event
746+
pseudo-header fields (e.g. `':method'`, `':path'`, etc). An `'error'` event
747747
will be emitted if the `getTrailers` callback attempts to set such header
748748
fields.
749749

750-
The `:method` and `:path` pseudoheaders are not specified within `headers`,
750+
The `:method` and `:path` pseudo-headers are not specified within `headers`,
751751
they respectively default to:
752752

753753
* `:method` = `'GET'`
@@ -774,7 +774,7 @@ On the client, `Http2Stream` instances are created and returned when either the
774774
`'push'` event.
775775

776776
*Note*: The `Http2Stream` class is a base for the [`ServerHttp2Stream`][] and
777-
[`ClientHttp2Stream`][] classes, each of which are used specifically by either
777+
[`ClientHttp2Stream`][] classes, each of which is used specifically by either
778778
the Server or Client side, respectively.
779779

780780
All `Http2Stream` instances are [`Duplex`][] streams. The `Writable` side of the
@@ -798,7 +798,7 @@ On the client side, instances of [`ClientHttp2Stream`][] are created when the
798798
`http2session.request()` may not be immediately ready for use if the parent
799799
`Http2Session` has not yet been fully established. In such cases, operations
800800
called on the `Http2Stream` will be buffered until the `'ready'` event is
801-
emitted. User code should rarely, if ever, have need to handle the `'ready'`
801+
emitted. User code should rarely, if ever, need to handle the `'ready'`
802802
event directly. The ready status of an `Http2Stream` can be determined by
803803
checking the value of `http2stream.id`. If the value is `undefined`, the stream
804804
is not yet ready for use.
@@ -1048,7 +1048,7 @@ added: v8.4.0
10481048
-->
10491049

10501050
The `'headers'` event is emitted when an additional block of headers is received
1051-
for a stream, such as when a block of `1xx` informational headers are received.
1051+
for a stream, such as when a block of `1xx` informational headers is received.
10521052
The listener callback is passed the [Headers Object][] and flags associated with
10531053
the headers.
10541054

@@ -1198,7 +1198,7 @@ server.on('stream', (stream) => {
11981198

11991199
When set, the `options.getTrailers()` function is called immediately after
12001200
queuing the last chunk of payload data to be sent. The callback is passed a
1201-
single object (with a `null` prototype) that the listener may used to specify
1201+
single object (with a `null` prototype) that the listener may use to specify
12021202
the trailing header fields to send to the peer.
12031203

12041204
```js
@@ -1215,7 +1215,7 @@ server.on('stream', (stream) => {
12151215
```
12161216

12171217
*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2
1218-
"pseudo-header" fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
1218+
pseudo-header fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
12191219
will be emitted if the `getTrailers` callback attempts to set such header
12201220
fields.
12211221

@@ -1272,7 +1272,7 @@ requests.
12721272

12731273
When set, the `options.getTrailers()` function is called immediately after
12741274
queuing the last chunk of payload data to be sent. The callback is passed a
1275-
single object (with a `null` prototype) that the listener may used to specify
1275+
single object (with a `null` prototype) that the listener may use to specify
12761276
the trailing header fields to send to the peer.
12771277

12781278
```js
@@ -1299,7 +1299,7 @@ server.on('close', () => fs.closeSync(fd));
12991299
```
13001300

13011301
*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2
1302-
"pseudo-header" fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
1302+
pseudo-header fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
13031303
will be emitted if the `getTrailers` callback attempts to set such header
13041304
fields.
13051305

@@ -1331,7 +1331,7 @@ of the given file:
13311331

13321332
If an error occurs while attempting to read the file data, the `Http2Stream`
13331333
will be closed using an `RST_STREAM` frame using the standard `INTERNAL_ERROR`
1334-
code. If the `onError` callback is defined it will be called, otherwise
1334+
code. If the `onError` callback is defined, then it will be called. Otherwise
13351335
the stream will be destroyed.
13361336

13371337
Example using a file path:
@@ -1391,7 +1391,7 @@ default behavior is to destroy the stream.
13911391

13921392
When set, the `options.getTrailers()` function is called immediately after
13931393
queuing the last chunk of payload data to be sent. The callback is passed a
1394-
single object (with a `null` prototype) that the listener may used to specify
1394+
single object (with a `null` prototype) that the listener may use to specify
13951395
the trailing header fields to send to the peer.
13961396

13971397
```js
@@ -1408,7 +1408,7 @@ server.on('stream', (stream) => {
14081408
```
14091409

14101410
*Note*: The HTTP/1 specification forbids trailers from containing HTTP/2
1411-
"pseudo-header" fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
1411+
pseudo-header fields (e.g. `':status'`, `':path'`, etc). An `'error'` event
14121412
will be emitted if the `getTrailers` callback attempts to set such header
14131413
fields.
14141414

@@ -1478,7 +1478,7 @@ an `Http2Session` object associated with the `Http2Server`.
14781478
added: v8.5.0
14791479
-->
14801480

1481-
If an `ServerHttp2Stream` emits an `'error'` event, it will be forwarded here.
1481+
If a `ServerHttp2Stream` emits an `'error'` event, it will be forwarded here.
14821482
The stream will already be destroyed when this event is triggered.
14831483

14841484
#### Event: 'stream'
@@ -1633,6 +1633,15 @@ changes:
16331633
* `options` {Object}
16341634
* `maxDeflateDynamicTableSize` {number} Sets the maximum dynamic table size
16351635
for deflating header fields. **Default:** `4Kib`
1636+
* `maxSessionMemory`{number} Sets the maximum memory that the `Http2Session`
1637+
is permitted to use. The value is expressed in terms of number of megabytes,
1638+
e.g. `1` equal 1 megabyte. The minimum value allowed is `1`. **Default:**
1639+
`10`. This is a credit based limit, existing `Http2Stream`s may cause this
1640+
limit to be exceeded, but new `Http2Stream` instances will be rejected
1641+
while this limit is exceeded. The current number of `Http2Stream` sessions,
1642+
the current memory use of the header compression tables, current data
1643+
queued to be sent, and unacknowledged PING and SETTINGS frames are all
1644+
counted towards the current limit.
16361645
* `maxHeaderListPairs` {number} Sets the maximum number of header entries.
16371646
**Default:** `128`. The minimum value is `4`.
16381647
* `maxOutstandingPings` {number} Sets the maximum number of outstanding,
@@ -1655,7 +1664,7 @@ changes:
16551664
* `http2.constants.PADDING_STRATEGY_ALIGNED` - Will *attempt* to apply
16561665
enough padding to ensure that the total frame length, including the
16571666
9-byte header, is a multiple of 8. For each frame, however, there is a
1658-
maxmimum allowed number of padding bytes that is determined by current
1667+
maximum allowed number of padding bytes that is determined by current
16591668
flow control state and settings. If this maximum is less than the
16601669
calculated amount needed to ensure alignment, the maximum will be used
16611670
and the total frame length will *not* necessarily be aligned at 8 bytes.
@@ -1711,6 +1720,15 @@ changes:
17111720
`false`. See the [`'unknownProtocol'`][] event. See [ALPN negotiation][].
17121721
* `maxDeflateDynamicTableSize` {number} Sets the maximum dynamic table size
17131722
for deflating header fields. **Default:** `4Kib`
1723+
* `maxSessionMemory`{number} Sets the maximum memory that the `Http2Session`
1724+
is permitted to use. The value is expressed in terms of number of megabytes,
1725+
e.g. `1` equal 1 megabyte. The minimum value allowed is `1`. **Default:**
1726+
`10`. This is a credit based limit, existing `Http2Stream`s may cause this
1727+
limit to be exceeded, but new `Http2Stream` instances will be rejected
1728+
while this limit is exceeded. The current number of `Http2Stream` sessions,
1729+
the current memory use of the header compression tables, current data
1730+
queued to be sent, and unacknowledged PING and SETTINGS frames are all
1731+
counted towards the current limit.
17141732
* `maxHeaderListPairs` {number} Sets the maximum number of header entries.
17151733
**Default:** `128`. The minimum value is `4`.
17161734
* `maxOutstandingPings` {number} Sets the maximum number of outstanding,
@@ -1733,7 +1751,7 @@ changes:
17331751
* `http2.constants.PADDING_STRATEGY_ALIGNED` - Will *attempt* to apply
17341752
enough padding to ensure that the total frame length, including the
17351753
9-byte header, is a multiple of 8. For each frame, however, there is a
1736-
maxmimum allowed number of padding bytes that is determined by current
1754+
maximum allowed number of padding bytes that is determined by current
17371755
flow control state and settings. If this maximum is less than the
17381756
calculated amount needed to ensure alignment, the maximum will be used
17391757
and the total frame length will *not* necessarily be aligned at 8 bytes.
@@ -1794,6 +1812,15 @@ changes:
17941812
* `options` {Object}
17951813
* `maxDeflateDynamicTableSize` {number} Sets the maximum dynamic table size
17961814
for deflating header fields. **Default:** `4Kib`
1815+
* `maxSessionMemory`{number} Sets the maximum memory that the `Http2Session`
1816+
is permitted to use. The value is expressed in terms of number of megabytes,
1817+
e.g. `1` equal 1 megabyte. The minimum value allowed is `1`. **Default:**
1818+
`10`. This is a credit based limit, existing `Http2Stream`s may cause this
1819+
limit to be exceeded, but new `Http2Stream` instances will be rejected
1820+
while this limit is exceeded. The current number of `Http2Stream` sessions,
1821+
the current memory use of the header compression tables, current data
1822+
queued to be sent, and unacknowledged PING and SETTINGS frames are all
1823+
counted towards the current limit.
17971824
* `maxHeaderListPairs` {number} Sets the maximum number of header entries.
17981825
**Default:** `128`. The minimum value is `1`.
17991826
* `maxOutstandingPings` {number} Sets the maximum number of outstanding,
@@ -1820,7 +1847,7 @@ changes:
18201847
* `http2.constants.PADDING_STRATEGY_ALIGNED` - Will *attempt* to apply
18211848
enough padding to ensure that the total frame length, including the
18221849
9-byte header, is a multiple of 8. For each frame, however, there is a
1823-
maxmimum allowed number of padding bytes that is determined by current
1850+
maximum allowed number of padding bytes that is determined by current
18241851
flow control state and settings. If this maximum is less than the
18251852
calculated amount needed to ensure alignment, the maximum will be used
18261853
and the total frame length will *not* necessarily be aligned at 8 bytes.
@@ -2162,8 +2189,8 @@ req.end('Jane');
21622189

21632190
The Compatibility API has the goal of providing a similar developer experience
21642191
of HTTP/1 when using HTTP/2, making it possible to develop applications
2165-
that supports both [HTTP/1][] and HTTP/2. This API targets only the
2166-
**public API** of the [HTTP/1][], however many modules uses internal
2192+
that support both [HTTP/1][] and HTTP/2. This API targets only the
2193+
**public API** of the [HTTP/1][]. However many modules use internal
21672194
methods or state, and those _are not supported_ as it is a completely
21682195
different implementation.
21692196

@@ -2191,7 +2218,7 @@ the status message for HTTP codes is ignored.
21912218

21922219
### ALPN negotiation
21932220

2194-
ALPN negotiation allows to support both [HTTPS][] and HTTP/2 over
2221+
ALPN negotiation allows supporting both [HTTPS][] and HTTP/2 over
21952222
the same socket. The `req` and `res` objects can be either HTTP/1 or
21962223
HTTP/2, and an application **must** restrict itself to the public API of
21972224
[HTTP/1][], and detect if it is possible to use the more advanced
@@ -2233,7 +2260,7 @@ added: v8.4.0
22332260

22342261
A `Http2ServerRequest` object is created by [`http2.Server`][] or
22352262
[`http2.SecureServer`][] and passed as the first argument to the
2236-
[`'request'`][] event. It may be used to access a request status, headers and
2263+
[`'request'`][] event. It may be used to access a request status, headers, and
22372264
data.
22382265

22392266
It implements the [Readable Stream][] interface, as well as the
@@ -2294,7 +2321,7 @@ console.log(request.headers);
22942321

22952322
See [Headers Object][].
22962323

2297-
*Note*: In HTTP/2, the request path, host name, protocol, and method are
2324+
*Note*: In HTTP/2, the request path, hostname, protocol, and method are
22982325
represented as special headers prefixed with the `:` character (e.g. `':path'`).
22992326
These special headers will be included in the `request.headers` object. Care
23002327
must be taken not to inadvertently modify these special headers or errors may
@@ -2327,7 +2354,7 @@ added: v8.4.0
23272354

23282355
* {string}
23292356

2330-
The request method as a string. Read only. Example:
2357+
The request method as a string. Read-only. Example:
23312358
`'GET'`, `'DELETE'`.
23322359

23332360
#### request.rawHeaders
@@ -2985,7 +3012,7 @@ If `name` is equal to `Http2Session`, the `PerformanceEntry` will contain the
29853012
following additional properties:
29863013

29873014
* `pingRTT` {number} The number of milliseconds elapsed since the transmission
2988-
of a `PING` frame and the reception of its acknowledgement. Only present if
3015+
of a `PING` frame and the reception of its acknowledgment. Only present if
29893016
a `PING` frame has been sent on the `Http2Session`.
29903017
* `streamCount` {number} The number of `Http2Stream` instances processed by
29913018
the `Http2Session`.

lib/internal/http2/util.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ const IDX_OPTIONS_PADDING_STRATEGY = 4;
175175
const IDX_OPTIONS_MAX_HEADER_LIST_PAIRS = 5;
176176
const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
177177
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
178-
const IDX_OPTIONS_FLAGS = 8;
178+
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
179+
const IDX_OPTIONS_FLAGS = 9;
179180

180181
function updateOptionsBuffer(options) {
181182
var flags = 0;
@@ -219,6 +220,11 @@ function updateOptionsBuffer(options) {
219220
optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS] =
220221
Math.max(1, options.maxOutstandingSettings);
221222
}
223+
if (typeof options.maxSessionMemory === 'number') {
224+
flags |= (1 << IDX_OPTIONS_MAX_SESSION_MEMORY);
225+
optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY] =
226+
Math.max(1, options.maxSessionMemory);
227+
}
222228
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
223229
}
224230

0 commit comments

Comments
 (0)