Commit f341bac
authored
Support HTTP/2 after proxy CONNECT (#2250)
## Motivation
When an HTTPS request uses an HTTP proxy, AHC establishes a `CONNECT`
tunnel and then performs TLS with the target. If ALPN selects `h2`, the
tunnel path currently leaves the HTTP/1.1 codec in place. The target
then receives HTTP/1.1 bytes on a connection that negotiated HTTP/2 and
closes it.
## Modification
- Check the negotiated ALPN protocol after the target TLS handshake in
both proxy tunnel paths.
- When ALPN selects `h2`, upgrade the existing channel pipeline to
HTTP/2 and register the physical tunnel connection with its existing
pool partition key.
- Preserve the existing HTTP/1.1 fallback and WebSocket behavior.
- Add regression tests using local HTTP and HTTPS `CONNECT` proxies with
a TLS HTTP/2 target.
- Verify that the upgraded tunnel is registered and reused for a second
request.
- Preserve the existing public tunneling method signatures for binary
compatibility.
## Result
HTTPS requests through HTTP and HTTPS `CONNECT` proxies now send HTTP/2
frames when the target negotiates `h2`. The regression tests verify
successful HTTP/2 responses and reuse of a single physical target
connection.
## Testing
- `./mvnw -pl client -Dtest=BasicHttp2Test,HttpsProxyTest test` — 60
tests passed.
- Full client test suite passed as part of `verify`; the local run then
stopped at artifact signing because `gpg` is not installed.
- `./mvnw -pl client -DskipTests -Dgpg.skip=true verify` — packaging and
API compatibility checks passed.
Fixes #22411 parent c8071b5 commit f341bac
4 files changed
Lines changed: 79 additions & 6 deletions
File tree
- client/src
- main/java/org/asynchttpclient/netty
- channel
- request
- test/java/org/asynchttpclient
- proxy
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
806 | 808 | | |
807 | 809 | | |
808 | 810 | | |
809 | | - | |
| 811 | + | |
810 | 812 | | |
811 | 813 | | |
812 | 814 | | |
813 | 815 | | |
814 | 816 | | |
815 | | - | |
| 817 | + | |
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
| |||
1084 | 1086 | | |
1085 | 1087 | | |
1086 | 1088 | | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
1087 | 1106 | | |
1088 | 1107 | | |
1089 | 1108 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1457 | 1457 | | |
1458 | 1458 | | |
1459 | 1459 | | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1460 | 1464 | | |
1461 | 1465 | | |
1462 | 1466 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
83 | 89 | | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
| |||
430 | 438 | | |
431 | 439 | | |
432 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
433 | 487 | | |
434 | 488 | | |
435 | 489 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
169 | 167 | | |
170 | 168 | | |
171 | 169 | | |
172 | | - | |
173 | | - | |
174 | 170 | | |
175 | 171 | | |
176 | 172 | | |
| |||
0 commit comments