-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http2: Introducing http/2 #14239
http2: Introducing http/2 #14239
Conversation
Just a thought: separating the new dep checkin to a separate commit might make review easier? |
This thing is going to be massive and difficult to review no matter how it is split up, unfortunately. |
nghttp2_pq_entry **q; | ||
/* Memory allocator */ | ||
nghttp2_mem *mem; | ||
/* The number of items sotred */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: typo on this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's in the upstream dependency so it would need to be fixed there :-) https://github.com/nghttp2/nghttp2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed upstream nghttp2/nghttp2#958
|
||
if (!common.hasCrypto) { | ||
common.skip('missing crypto'); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit: redundant after #14021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinking about it, I think I need to go add the crypto skip in a couple of the other tests.
Came up in downstream code review by @lucaslago nodejs/node#14239 (comment)
@jasnell We also split out the deps commits for node-inspect and for the inspector iirc; that worked out pretty well and did help with reviewing. :) |
Also, for N-API, async_hooks, and some other PRs, we used |
|
||
An object describing the current status of this `Http2Session`. | ||
|
||
#### http2session.priority(stream, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does the same thing as stream.priority(options)
, right? In that case I think I’d prefer not to expose it (same thing for rstStream
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, yes, but eventually this will support the ability to pass in a numeric stream identifier rather than the Http2Stream
object. The HTTP/2 spec allows priorities and rst_stream frames to be sent independently, even without a stream having been previously established.
The colon prefix in :status looks a bit odd to me. I'm sure there have been careful considerations made as to why that makes sense. Would you mind sharing the reasoning behind using colon prefixes? Thanks! |
@yoshuawuyts it's part of the HTTP2 spec: https://http2.github.io/http2-spec/#HttpResponse |
@mcollina cool, thanks for answering!
…On Sat, Jul 15, 2017, 14:47 Matteo Collina ***@***.***> wrote:
@yoshuawuyts <https://github.com/yoshuawuyts> it's part of the HTTP2
spec: https://http2.github.io/http2-spec/#HttpResponse
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14239 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACWleuhN8XM3Dk7G-OD3ZsFjZciMOVUsks5sOLThgaJpZM4OYrK1>
.
|
Awesome work! Above you said the following:
I tried looking in the documentation included in this PR, but couldn't figure out what these exceptions are. Can you ellaborate? Is the compatibility API just the same how the "spdy" module does the HTTP/2 -> 1 compatibility API or different somehow? I'm not really looking for a comparison to the "spdy" module, but thought if you knew that would help, otherwise would love to see the docs around what these differences are. |
@dougwilson .... I'm hoping to get that compat api documented this next week... Including those caveats. |
|
doc/api/errors.md
Outdated
<a id="ERR_HTTP2_STREAM_ERROR"></a> | ||
### ERR_HTTP2_STREAM_ERROR | ||
|
||
Used when a non-zero error code has been specified in an RST_STREAM frame. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`RST_STREAM`
?
|
||
To run the `http2` benchmarks, the `h2load` benchmarker must be used. The | ||
`h2load` tool is a component of the `nghttp2` project and may be installed | ||
from [nghttp.org][] or built from source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nghttp2.org
Thanks @jasnell ! Please feel free to ping me when you do, I would love to take a look. |
doc/api/http2.md
Outdated
[`tls.TLSSocket`]: tls.html | ||
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener | ||
[ClientHttp2Stream]: #http2_class_clienthttp2stream | ||
[Compatibility API: #http2_compatibility_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing ]
doc/api/http2.md
Outdated
[`net.Socket`]: net.html | ||
[`tls.TLSSocket`]: tls.html | ||
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener | ||
[ClientHttp2Stream]: #http2_class_clienthttp2stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to using in text,
[ServerHttp2Stream]: [ClientHttp2Stream]: [Http2Stream]:
should be:
[`ServerHttp2Stream`]: [`ClientHttp2Stream`]: [`Http2Stream`]:
doc/api/http2.md
Outdated
* `settings` {[Settings Object][]} | ||
* Returns: {Buffer} | ||
|
||
Returns a [Buffer][] instance containing serialized representation of the given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing reference for [Buffer][]
doc/api/http2.md
Outdated
* A new HTTP/2 `HEADERS` frame with a previously unused stream ID is received; | ||
* The `http2stream.pushStream()` method is called. | ||
|
||
On the client side, instances of [`ClientHttp2Stream`[] are created when the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ]
Issue with the first examples from the main doc: #14304 |
@dougwilson Some notable differences, off the top of my head:
|
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Backport-PR-URL: #14813 Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net> Backport-Reviewed-By: Timothy Gu <timothygu99@gmail.com> 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>
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
@jasnell https://nodejs.org/api/http2.html has many not rendered links now (just search |
AFAICT the md has has broken links (or rather links with no definition in the footer) in certain areas. Some were fixed in 85d7d97 |
Cross ref: #14857 |
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](nodejs/node#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](nodejs/node#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](nodejs/node#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](nodejs/node#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](nodejs/node#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](nodejs/node#14558) PR-URL: nodejs/node#14811
Setting don't land on v6.x. Assuming we are not going to backport this |
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: nodejs#14239 See: nodejs@b1909d3a70f9
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: #14239 See: b1909d3a70f9 PR-URL: #25997 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: #14239 See: b1909d3a70f9 PR-URL: #25997 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: nodejs#14239 See: nodejs@b1909d3a70f9 PR-URL: nodejs#25997 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: #14239 See: b1909d3a70f9 Backport-PR-URL: #27938 PR-URL: #25997 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
At long last: The initial experimental implementation of HTTP/2.
This is an accumulation of the work that has been done in the nodejs/http2
repository, squashed down to a couple of commits. The original commit
history has been preserved in the nodejs/http2 repository.
Contributors to this work include:
This PR introduces the nghttp2 C library as a new dependency. This library
provides the majority of the HTTP/2 protocol implementation, with the rest
of the code here providing the mapping of the library into a usable JS API.
Within src, a handful of new node_http2_.c and node_http2_.h files are
introduced. These provide the internal mechanisms that interface with nghttp
and define the
process.binding('http2')
interface.The JS API is defined within
internal/http2/*.js
.There are two APIs provided: Core and Compat.
The Core API is HTTP/2 specific and is designed to be as minimal and as
efficient as possible.
The Compat API is intended to be as close to the existing HTTP/1 API as
possible, with some exceptions.
Tests, documentation and initial benchmarks are included.
The
http2
module is gated by a new--expose-http2
command line flag.When used,
require('http2')
will be exposed to users. Note that thereis an existing
http2
module on npm that would be impacted by the introductionof this module, which is the main reason for gating this behind a flag.
When using
require('http2')
the first time, a process warning will beemitted indicating that an experimental feature is being used.
To run the benchmarks, the
h2load
tool (part of the nghttp project) isrequired:
./node benchmarks/http2/simple.js benchmarker=h2load
. Onlytwo benchmarks are currently available.
Additional configuration options to enable verbose debugging are provided:
The
--debug-http2
configuration option enables verbose debug statementsfrom the
src/node_http2_*
files. The--debug-nghttp2
enables the nghttplibrary's own verbose debug output. The
NODE_DEBUG=http2
enables JS-leveldebug output.
The following illustrates as simple HTTP/2 server and client interaction:
(The HTTP/2 client and server support both plain text and TLS connections)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
http2
[Edit:ofrobots: fixed github handle for Kelvin Jin]