Skip to content

Commit

Permalink
http: multiple fixes, tests and perf updates
Browse files Browse the repository at this point in the history
PR-URL: nodejs#178
Reviewed-By: Sebastiaan Deckers <sebdeckers83@gmail.com>
  • Loading branch information
jasnell committed Jul 14, 2017
1 parent 86daaa1 commit a8cd3ce
Show file tree
Hide file tree
Showing 31 changed files with 1,235 additions and 302 deletions.
81 changes: 46 additions & 35 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1233,41 +1233,6 @@ server.on('stream', (stream, headers, flags) => {
added: REPLACEME
-->

The `'timeout'` event is emitted when there is no activity on the Server for
a given number of milliseconds set using `http2server.setTimeout()`.

### http2.getDefaultSettings()
<!-- YAML
added: REPLACEME
-->

* Returns: {[Settings Object][]}

Returns an object containing the default settings for an `Http2Session`
instance. This method returns a new object instance every time it is called
so instances returned may be safely modified for use.

### http2.getPackedSettings(settings)
<!-- YAML
added: REPLACEME
-->

* `settings` {[Settings Object][]}
* Returns: {Buffer}

Returns a [Buffer][] instance containing serialized representation of the given
HTTP/2 settings as specified in the [HTTP/2][] specification. This is intended
for use with the `HTTP2-Settings` header field.

```js
const http2 = require('http2');

const packed = http2.getPackedSettings({ enablePush: false });

console.log(packed.toString('base64'));
// Prints: AAIAAAAA
```

### http2.createServer(options[, onRequestHandler])
<!-- YAML
added: REPLACEME
Expand Down Expand Up @@ -1464,6 +1429,52 @@ added: REPLACEME
| 0x0c | Inadequate Security | `http2.constants.NGHTTP2_INADEQUATE_SECURITY` |
| 0x0d | HTTP/1.1 Required | `http2.constants.NGHTTP2_HTTP_1_1_REQUIRED` |

The `'timeout'` event is emitted when there is no activity on the Server for
a given number of milliseconds set using `http2server.setTimeout()`.

### http2.getDefaultSettings()
<!-- YAML
added: REPLACEME
-->

* Returns: {[Settings Object][]}

Returns an object containing the default settings for an `Http2Session`
instance. This method returns a new object instance every time it is called
so instances returned may be safely modified for use.

### http2.getPackedSettings(settings)
<!-- YAML
added: REPLACEME
-->

* `settings` {[Settings Object][]}
* Returns: {Buffer}

Returns a [Buffer][] instance containing serialized representation of the given
HTTP/2 settings as specified in the [HTTP/2][] specification. This is intended
for use with the `HTTP2-Settings` header field.

```js
const http2 = require('http2');

const packed = http2.getPackedSettings({ enablePush: false });

console.log(packed.toString('base64'));
// Prints: AAIAAAAA
```

### http2.getUnpackedSettings(buf)
<!-- YAML
added: REPLACEME
-->

* `buf` {Buffer|Uint8Array} The packed settings
* Returns: {[Settings Object][]}

Returns a [Settings Object][] containing the deserialized settings from the
given `Buffer` as generated by `http2.getPackedSettings()`.

### Headers Object

Headers are represented as own-properties on JavaScript objects. The property
Expand Down
2 changes: 2 additions & 0 deletions lib/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
constants,
getDefaultSettings,
getPackedSettings,
getUnpackedSettings,
createServer,
createSecureServer,
connect
Expand All @@ -19,6 +20,7 @@ module.exports = {
constants,
getDefaultSettings,
getPackedSettings,
getUnpackedSettings,
createServer,
createSecureServer,
connect
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ E('ERR_HTTP2_INVALID_CONNECTION_HEADERS',
E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Value must not be undefined or null');
E('ERR_HTTP2_INVALID_INFO_STATUS',
(code) => `Invalid informational status code: ${code}`);
E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH',
'Packed settings length must be a multiple of six');
E('ERR_HTTP2_INVALID_PSEUDOHEADER',
(name) => `"${name}" is an invalid pseudoheader or is used incorrectly`);
E('ERR_HTTP2_INVALID_SESSION', 'The session has been destroyed');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Http2ServerResponse extends Stream {
code |= 0;
if (code >= 100 && code < 200)
throw new errors.RangeError('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED');
if (code < 200 || code > 999)
if (code < 200 || code > 599)
throw new errors.RangeError('ERR_HTTP2_STATUS_INVALID', code);
state.statusCode = code;
}
Expand Down
Loading

0 comments on commit a8cd3ce

Please sign in to comment.