Skip to content

Commit a31ef60

Browse files
committed
fix(client): preserve request on ALPN fallback
Reuse the prepared request when automatic HTTP/2 negotiation falls back to HTTP/1.1. This preserves trace-time signing and other mutations made after the request copy was created. Cover the TLS fallback path with a trace-added Authorization header.
1 parent ed8303c commit a31ef60

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/http_client.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ function _do_incoming!(
815815
catch err
816816
_drop_h2_conn!(client, proxy_plan, conn)
817817
if protocol == :auto && _should_fallback_h2_to_h1(err)
818-
send_request = _copy_request_for_send(current_request, retry_attempt == 1)
819818
_roundtrip_incoming!(
820819
client.transport,
821820
current_address,

test/http_integration_tests.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ end
7777
)
7878
laddr = TL.addr(listener)::NC.SocketAddrV4
7979
address = ND.join_host_port("127.0.0.1", Int(laddr.port))
80+
seen_authorization = Ref{Union{Nothing,String}}(nothing)
8081
server = HT.serve!(listener) do request
82+
seen_authorization[] = HT.header(request.headers, "Authorization", nothing)
8183
payload = collect(codeunits("tls-h1:" * request.target))
8284
return HT.Response(200, HT.BytesBody(payload); content_length = length(payload))
8385
end
@@ -93,9 +95,22 @@ end
9395
prefer_http2 = true,
9496
)
9597
try
96-
response = HT.get!(client, address, "/auto-tls"; secure = true, protocol = :auto)
98+
trace = function(event)
99+
if event isa HT.RequestEvent
100+
HT.setheader(event.request.headers, "Authorization", "Signature trace-time")
101+
end
102+
return nothing
103+
end
104+
response = HT.request(
105+
trace,
106+
"GET",
107+
"https://$(address)/auto-tls";
108+
client,
109+
protocol = :auto,
110+
)
97111
@test response.status == 200
98-
@test String(_read_all_integration(response.body)) == "tls-h1:/auto-tls"
112+
@test String(response.body) == "tls-h1:/auto-tls"
113+
@test seen_authorization[] == "Signature trace-time"
99114
finally
100115
close(client)
101116
HT.forceclose(server)

0 commit comments

Comments
 (0)