forwardemail / forwardemail/superagent

Does superagent support ALPN for http2 ?

Open
#1,754 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

The documentation on http2 currently reads
https://github.com/visionmedia/superagent/blob/92b1435f4fd02193b12c6cf14f6ef4ca02b22bd6/docs/index.md?plain=1#L98
This sounds like the superagent will try to force the http2 only when the http2() method is called. When a request is made _without_ the http2() method superagent will by default use the http2 and callbacks to http1 if the server does not support http2 (presumably using the ALNP?).

But at the moment (tested with superagent 8.0.0) when making a request using a superagent without the `http2()` to a server created by `http2.createSecureServer` without the 'allowHTTP1' options will result in an 'Unknown ALPN Protocol, expected `h2` to be available' error on the server side.

According to https://nodejs.org/api/http2.html#event-unknownprotocol, this means the client

> either does not send an ALPN extension or sends an ALPN extension that does not include HTTP/2 (h2).

Does this contradict what the superagent's documentation seems to be implying? Some clarification on the expected behavior will be very helpful. Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.