Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bb91834
http: move utcDate to internal/http.js
jasnell Oct 17, 2016
c6472e7
tls: add tlsSocket.disableRenegotiation()
jasnell Nov 4, 2016
a22543c
deps: add nghttp2 dependency
jasnell Jul 17, 2017
ea75860
http2: introducing HTTP/2
jasnell Jul 17, 2017
837dfe4
http2: add tests and benchmarks
jasnell Jul 17, 2017
e4b9149
http2: remove redundant return in test
jasnell Jul 17, 2017
8357bd0
http2: fix documentation nits
jasnell Jul 17, 2017
295e4b1
doc: include http2.md in all.md
jasnell Jul 17, 2017
9cb0611
test: fix flakiness in test-http2-client-upload
jasnell Jul 18, 2017
fefe2cb
test: fix flaky test-http2-client-unescaped-path on osx
jasnell Jul 18, 2017
a93b3b8
http2: fix abort when client.destroy inside end event
jasnell Jul 19, 2017
2289352
http2: refinement and test for socketError
jasnell Jul 19, 2017
d74da3a
http2: fix socketOnTimeout and a segfault
jasnell Jul 19, 2017
07758c8
http2: add range support for respondWith{File|FD}
jasnell Jul 22, 2017
0d8bf4c
http2: doc and fixes to the Compatibility API
mcollina Jul 24, 2017
2db82e0
http2: make writeHead behave like HTTP/1.
mcollina Jul 24, 2017
6bc7cc2
http2: address initial pr feedback
jasnell Jul 31, 2017
0a5fe92
http2: refactor trailers API
jasnell Jul 31, 2017
7c5825b
http2: get trailers working with the compat api
jasnell Jul 31, 2017
0e13eb6
http2: use static allocated arrays
jasnell Aug 1, 2017
a2045e9
http2: minor cleanup
jasnell Aug 1, 2017
c9c9e92
http2: fix documentation errors
jasnell Aug 1, 2017
ea2a35f
http2: add some doc detail for invalid header chars
jasnell Aug 1, 2017
69a0783
http2: fix compilation error after V8 update
jasnell Aug 3, 2017
ba2744e
http2: fix linting after rebase
jasnell Aug 3, 2017
c58115d
http2: fix flakiness in timeout
jasnell Aug 3, 2017
79e14a9
http2: rename some nghttp2 stream flags
kjin Aug 5, 2017
38f55ea
test: add crypto check to http2 tests
danbev Aug 7, 2017
ede1161
doc: fix http2 sample code for http2.md
kakts Aug 7, 2017
ea3c8c7
doc: explain browser support of http/2 without SSL
giltayar Aug 7, 2017
e344b91
src,http2: DRY header/trailer handling code up
addaleax Aug 8, 2017
70f7c54
test: increase http2 coverage
michaalbert Aug 8, 2017
1129943
http2: improve perf of passing headers to C++
addaleax Aug 9, 2017
5db4971
src: remove unused http2_socket_buffer from env
addaleax Aug 10, 2017
a6c1571
http2: use per-environment buffers
addaleax Aug 10, 2017
01bada5
http2: name padding buffer fields
addaleax Aug 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
http2: fix documentation errors
PR-URL: #14239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
jasnell committed Aug 13, 2017
commit c9c9e9270ebe5bb15cf74078e5fd01ba1dc25faf
78 changes: 42 additions & 36 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1803,10 +1803,10 @@ req.end('Jane');

## Compatibility API

The Compatibility API has the goal of providing a similar developer experience of
HTTP/1 when using HTTP/2, making it possible to develop applications
that supports both [HTTP/1](HTTP/1) and HTTP/2. This API targets only the **public
API** of the [HTTP/1](HTTP/1), however many modules uses internal
The Compatibility API has the goal of providing a similar developer experience
of HTTP/1 when using HTTP/2, making it possible to develop applications
that supports both [HTTP/1](HTTP/1) and HTTP/2. This API targets only the
**public API** of the [HTTP/1](HTTP/1), however many modules uses internal
methods or state, and those _are not supported_ as it is a completely
different implementation.

Expand All @@ -1823,7 +1823,7 @@ const server = http2.createServer((req, res) => {
});
```

In order to create a mixed [HTTPs](https) and HTTP/2 server, refer to the
In order to create a mixed [HTTPS](https) and HTTP/2 server, refer to the
[ALPN negotiation](alpn-negotiation) section.
Upgrading from non-tls HTTP/1 servers is not supported.

Expand All @@ -1834,8 +1834,8 @@ the status message for HTTP codes is ignored.

### ALPN negotiation

ALPN negotiation allows to support both [HTTPs](https) and HTTP/2 over
the same socket. the `req` and `res` object could be either HTTP/1 or
ALPN negotiation allows to support both [HTTPS](https) and HTTP/2 over
the same socket. The `req` and `res` objects can be either HTTP/1 or
HTTP/2, and an application **must** restrict itself to the public API of
[HTTP/1](), and detect if it is possible to use the more advanced
features of HTTP/2.
Expand All @@ -1855,7 +1855,7 @@ const server = createSecureServer(
).listen(4443);

function onRequest(req, res) {
// detects if it is a HTTPs request or HTTP/2
// detects if it is a HTTPS request or HTTP/2
const { socket: { alpnProtocol } } = request.httpVersion === '2.0' ?
request.stream.session : request;
response.writeHead(200, { 'content-type': 'application/json' });
Expand All @@ -1866,7 +1866,7 @@ function onRequest(req, res) {
}
```

The `'request'` event works identically on both [HTTPs](https) and
The `'request'` event works identically on both [HTTPS](https) and
HTTP/2.

### Class: http2.Http2ServerRequest
Expand All @@ -1875,8 +1875,9 @@ added: REPLACEME
-->

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

It implements the [Readable Stream][] interface, as well as the
following additional events, methods, and properties.
Expand Down Expand Up @@ -1907,9 +1908,9 @@ added: REPLACEME

* `error` {Error}

Calls `destroy()` on the [Http2Stream]() that received the `ServerRequest`. If `error`
is provided, an `'error'` event is emitted and `error` is passed as an argument
to any listeners on the event.
Calls `destroy()` on the [Http2Stream]() that received the `ServerRequest`. If
`error` is provided, an `'error'` event is emitted and `error` is passed as an
argument to any listeners on the event.

It does nothing if the stream was already destroyed.

Expand Down Expand Up @@ -2201,7 +2202,7 @@ added: REPLACEME
* `name` {string}
* Returns: {string}

Reads out a header that's already been queued but not sent to the client.
Reads out a header that has already been queued but not sent to the client.
Note that the name is case insensitive.

Example:
Expand Down Expand Up @@ -2291,7 +2292,7 @@ added: REPLACEME

* `name` {string}

Removes a header that's queued for implicit sending.
Removes a header that has been queued for implicit sending.

Example:

Expand Down Expand Up @@ -2339,9 +2340,9 @@ response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
Attempting to set a header field name or value that contains invalid characters
will result in a [`TypeError`][] being thrown.

When headers have been set with [`response.setHeader()`][], they will be merged with
any headers passed to [`response.writeHead()`][], with the headers passed to
[`response.writeHead()`][] given precedence.
When headers have been set with [`response.setHeader()`][], they will be merged
with any headers passed to [`response.writeHead()`][], with the headers passed
to [`response.writeHead()`][] given precedence.

```js
// returns content-type = text/plain
Expand All @@ -2366,9 +2367,9 @@ provided, then it is added as a listener on the `'timeout'` event on
the response object.

If no `'timeout'` listener is added to the request, the response, or
the server, then [`Http2Stream`]()s are destroyed when they time out. If a handler is
assigned to the request, the response, or the server's `'timeout'` events,
timed out sockets must be handled explicitly.
the server, then [`Http2Stream`]()s are destroyed when they time out. If a
handler is assigned to the request, the response, or the server's `'timeout'`
events, timed out sockets must be handled explicitly.

Returns `response`.

Expand Down Expand Up @@ -2478,7 +2479,8 @@ buffer. Returns `false` if all or part of the data was queued in user memory.
added: REPLACEME
-->

Throws an error as the `'continue'` flow is not current implemented. Added for parity with [HTTP/1]().
Throws an error as the `'continue'` flow is not current implemented. Added for
parity with [HTTP/1]().

### response.writeHead(statusCode[, statusMessage][, headers])
<!-- YAML
Expand All @@ -2491,7 +2493,11 @@ added: REPLACEME

Sends a response header to the request. The status code is a 3-digit HTTP
status code, like `404`. The last argument, `headers`, are the response headers.
For compatibility with [HTTP/1](), one can give a human-readable `statusMessage` as the second argument, which will be silenty ignored and emit a warning.

For compatibility with [HTTP/1](), a human-readable `statusMessage` may be
passed as the second argument. However, because the `statusMessage` has no
meaning within HTTP/2, the argument will have no effect and a process warning
will be emitted.

Example:

Expand All @@ -2502,15 +2508,22 @@ response.writeHead(200, {
'Content-Type': 'text/plain' });
```

This method must only be called once on a message and it must
be called before [`response.end()`][] is called.
Note that Content-Length is given in bytes not characters. The
`Buffer.byteLength()` API may be used to determine the number of bytes in a
given encoding. On outbound messages, Node.js does not check if Content-Length
and the length of the body being transmitted are equal or not. However, when
receiving messages, Node.js will automatically reject messages when the
Content-Length does not match the actual payload size.

This method may be called at most one time on a message before
[`response.end()`][] is called.

If [`response.write()`][] or [`response.end()`][] are called before calling
this, the implicit/mutable headers will be calculated and call this function.

When headers have been set with [`response.setHeader()`][], they will be merged with
any headers passed to [`response.writeHead()`][], with the headers passed to
[`response.writeHead()`][] given precedence.
When headers have been set with [`response.setHeader()`][], they will be merged
with any headers passed to [`response.writeHead()`][], with the headers passed
to [`response.writeHead()`][] given precedence.

```js
// returns content-type = text/plain
Expand All @@ -2522,13 +2535,6 @@ const server = http2.createServer((req, res) => {
});
```

Note that Content-Length is given in bytes not characters. The above example
works because the string `'hello world'` contains only single byte characters.
If the body contains higher coded characters then `Buffer.byteLength()`
should be used to determine the number of bytes in a given encoding.
And Node.js does not check whether Content-Length and the length of the body
which has been transmitted are equal or not.

Attempting to set a header field name or value that contains invalid characters
will result in a [`TypeError`][] being thrown.

Expand Down