From b83d1f87311293b43efafeddf790d325b227d571 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Thu, 9 May 2024 09:11:47 +0100 Subject: [PATCH 1/2] Minor cleanup --- test/client.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/client.jl b/test/client.jl index ad76ad9f..1f07fce6 100644 --- a/test/client.jl +++ b/test/client.jl @@ -38,25 +38,28 @@ end # 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) + # Accept the first request (the CONNECT request) unconditionally. 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 + + # Test that we receive something that looks like a TLS client hello # (indicating that we tried to upgrade the connection to TLS) line = readline(sock) @test startswith(line, "\x16") + close(sock) end - @test_throws HTTP.RequestError HTTP.head("https://$httpbin.com"; proxy="http://localhost:8082", readtimeout=1, retry=false) + @test_throws HTTP.RequestError HTTP.head("https://$httpbin.com"; + proxy="http://localhost:8082", + readtimeout=1, + retry=false) finally close(proxy) HTTP.Connections.closeall() From 84cf9ebecbc225354098d9e296223c1f7864ef24 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Thu, 9 May 2024 12:54:29 +0100 Subject: [PATCH 2/2] Read a byte rather than messing with strings --- test/client.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/client.jl b/test/client.jl index 1f07fce6..3dddb396 100644 --- a/test/client.jl +++ b/test/client.jl @@ -51,8 +51,7 @@ end # Test that we receive something that looks like a TLS client hello # (indicating that we tried to upgrade the connection to TLS) - line = readline(sock) - @test startswith(line, "\x16") + @test read(sock, UInt8) == 0x16 close(sock) end