Commit 6345cf2
net.http: enable HTTP/2 by default for https requests (#27384)
* net.http: enable HTTP/2 by default for https requests
Flip the `enable_http2` default on Request and FetchConfig from false to true,
so https requests made with http.fetch / http.get negotiate HTTP/2 when the
server offers it (ALPN `h2`), and transparently fall back to HTTP/1.1 otherwise.
Set `enable_http2: false` to force HTTP/1.1.
This is opt-out rather than opt-in now that the HTTP/2 client supports
redirects, streaming response callbacks, and flow control, and has been
exercised against real servers. Plain http:// is unaffected (no ALPN), and the
Windows SChannel backend keeps using HTTP/1.1 until it gains ALPN (#27383).
Updates the gated real-server test to assert the new default (a plain get()
negotiates HTTP/2) and that `enable_http2: false` still forces HTTP/1.1.
Notes for review:
- No latency regression: the client sends the preface, SETTINGS, and the
request together without waiting for the server's SETTINGS, so there is no
extra round trip; HPACK also shrinks request headers.
- Each fetch is still one connection / one request (no pooling yet), so the
multiplexing win does not yet apply; this change is about defaulting to the
newer protocol, with pooling/multiplexing as a follow-up.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* net.http: gate default-h2 network test on Windows; refresh ALPN comment
Address review feedback on enabling HTTP/2 by default:
- test_http2_fetch_real_server now skips on the default Windows/SChannel
configuration (`$if windows && !no_vschannel ?`), since SChannel has no ALPN
yet (#27383) and a default get() there stays on HTTP/1.1. The path remains
covered with `-d no_vschannel` (mbedtls client).
- Refresh the now-stale comment in backend.c.v: with enable_http2 defaulting to
true, ordinary get()/fetch() calls advertise ALPN and use HTTP/2 when the
server selects it (opt out with enable_http2: false).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Richard Wheeler <quaesitor.scientiam@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 35ffbab commit 6345cf2
4 files changed
Lines changed: 20 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
92 | | - | |
93 | | - | |
| 100 | + | |
| 101 | + | |
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
0 commit comments