Skip to content
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

Fix 1172 #1174

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/clientlayers/ConnectionRequest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ function connectionlayer(handler)
return r
end
if target_url.scheme in ("https", "wss")
io = Connections.sslupgrade(socket_type_tls, io, target_url.host; readtimeout=readtimeout, kw...)
InnerIOType = sockettype(target_url, socket_type, socket_type_tls, get(kw, :sslconfig, nothing))
io = Connections.sslupgrade(InnerIOType, io, target_url.host; readtimeout=readtimeout, kw...)
end
req.headers = filter(x->x.first != "Proxy-Authorization", req.headers)
end
Expand Down
30 changes: 30 additions & 0 deletions test/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ end
@test_throws ArgumentError HTTP.get("https://$httpbin/ip", sslconfig=MbedTLS.SSLConfig(false), socket_type_tls=OpenSSL.SSLStream)
end

@testset "issue 1172" begin
# Connections through a proxy need to choose an IOType twice rather than
# just once.
# https://github.com/JuliaWeb/HTTP.jl/issues/1172

# This proxy accepts two requests, ignoring the content of the request and
# returning 200 each time.
proxy = listen(IPv4(0), 8082)
try
@async begin
sock = accept(proxy)
while isopen(sock)
line = readline(sock)
@show 1, line
isempty(line) && break
end
write(sock, "HTTP/1.1 200\r\n\r\n")
# Test that we receive something that looks like a client hello
# (indicating that we tried to upgrade the connection to TLS)
line = readline(sock)
@test startswith(line, "\x16")
end

@test_throws HTTP.RequestError HTTP.head("https://$httpbin.com"; proxy="http://localhost:8082", readtimeout=1, retry=false)
finally
close(proxy)
HTTP.Connections.closeall()
end
end

@testset "@client macro" begin
@eval module MyClient
using HTTP
Expand Down
Loading