Skip to content

Commit 0497b52

Browse files
committed
More fixes for dep updates
1 parent d9f1947 commit 0497b52

File tree

6 files changed

+38
-39
lines changed

6 files changed

+38
-39
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
99
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1010
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1111
LibAwsCommon = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
12-
LibAwsHTTP = "ce851869-0d7a-41e7-95ef-2d4cb63876dd"
12+
LibAwsHTTPFork = "d3f1d20b-921e-4930-8491-471e0be3121a"
1313
LibAwsIO = "a5388770-19df-4151-b103-3d71de896ddf"
1414
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1515
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
@@ -20,8 +20,8 @@ URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
2020

2121
[compat]
2222
JSON = "0.21.4"
23+
LibAwsHTTPFork = "1.0.2"
2324
LibAwsIO = "1.2.0"
24-
LibAwsHTTP = "1.2.0"
2525
PrecompileTools = "1.2.1"
2626
julia = "1.10"
2727

src/HTTP.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module HTTP
22

33
using CodecZlib, URIs, Mmap, Base64, Dates, Sockets
4-
using LibAwsCommon, LibAwsIO, LibAwsHTTP
4+
using LibAwsCommon, LibAwsIO, LibAwsHTTPFork
55

66
export @logfmt_str, common_logfmt, combined_logfmt
77
export WebSockets
@@ -82,7 +82,7 @@ end
8282

8383
function __init__()
8484
allocator = default_aws_allocator()
85-
LibAwsHTTP.init(allocator)
85+
LibAwsHTTPFork.init(allocator)
8686
# intialize c functions
8787
on_acquired[] = @cfunction(c_on_acquired, Cvoid, (Ptr{Cvoid}, Cint, Ptr{aws_retry_token}, Ptr{Cvoid}))
8888
# on_shutdown[] = @cfunction(c_on_shutdown, Cvoid, (Ptr{Cvoid}, Cint, Ptr{Cvoid}))

src/client/client.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Base.@kwdef struct ClientSettings
1414
keep_alive_timeout_sec::Int = 0
1515
keep_alive_max_failed_probes::Int = 0
1616
keepalive::Bool = false
17+
response_first_byte_timeout_ms::Int = 0
1718
ssl_cert::Union{Nothing, String} = nothing
1819
ssl_key::Union{Nothing, String} = nothing
1920
ssl_capath::Union{Nothing, String} = nothing
@@ -100,6 +101,7 @@ function Client(cs::ClientSettings)
100101
client.socket_options = aws_socket_options(
101102
AWS_SOCKET_STREAM, # socket type
102103
cs.socket_domain == :ipv4 ? AWS_SOCKET_IPV4 : AWS_SOCKET_IPV6, # socket domain
104+
AWS_SOCKET_IMPL_PLATFORM_DEFAULT, # aws_socket_impl_type
103105
cs.connect_timeout_ms,
104106
cs.keep_alive_interval_sec,
105107
cs.keep_alive_timeout_sec,
@@ -178,6 +180,7 @@ function Client(cs::ClientSettings)
178180
cs.bootstrap,
179181
typemax(Csize_t), # initial_window_size::Csize_t
180182
pointer(FieldRef(client, :socket_options)),
183+
cs.response_first_byte_timeout_ms,
181184
(cs.scheme == "https" || cs.scheme == "wss") ? pointer(FieldRef(client, :tls_options)) : C_NULL,
182185
cs.http2_prior_knowledge,
183186
C_NULL, # monitoring_options::Ptr{aws_http_connection_monitoring_options}

src/precompile.jl

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,30 @@ using PrecompileTools: @setup_workload, @compile_workload
33
try
44
@setup_workload begin
55
HTTP.__init__()
6-
@info "HTTP initialized"
7-
HTTP.set_log_level!(4)
6+
# HTTP.set_log_level!(4)
87
gzip_data(data::String) = read(GzipCompressorStream(IOBuffer(data)))
9-
# random port in the dynamic/private range (49152–65535) which are are
10-
# least likely to be used by well-known services
11-
_port = 57813
12-
server = HTTP.serve!("0.0.0.0", _port; listenany=true) do req
13-
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response"))
14-
end
15-
# listenany allows changing port if that one is already in use, so check the actual port
16-
_port = HTTP.port(server)
17-
url = "http://localhost:$_port"
18-
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
19-
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
20-
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]
21-
@info "HTTP server started on port $_port"
22-
try
23-
withenv(env...) do
24-
@compile_workload begin
25-
@show HTTP.get(url)
26-
end
8+
@compile_workload begin
9+
# random port in the dynamic/private range (49152–65535) which are are
10+
# least likely to be used by well-known services
11+
_port = 57813
12+
server = HTTP.serve!("0.0.0.0", _port; listenany=true) do req
13+
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response"))
14+
end
15+
# listenany allows changing port if that one is already in use, so check the actual port
16+
_port = HTTP.port(server)
17+
url = "http://localhost:$_port"
18+
try
19+
HTTP.get(url)
20+
finally
21+
close(server)
22+
yield() # needed on 1.9 to avoid some issue where it seems a task doesn't stop before serialization
23+
server = nothing
24+
close_all_clients!()
25+
close_default_aws_server_bootstrap!()
26+
close_default_aws_client_bootstrap!()
27+
close_default_aws_host_resolver!()
28+
close_default_aws_event_loop_group!()
2729
end
28-
finally
29-
@info "Shutting down HTTP server"
30-
close(server)
31-
@info "HTTP server shut down"
32-
yield() # needed on 1.9 to avoid some issue where it seems a task doesn't stop before serialization
33-
server = nothing
34-
close_all_clients!()
35-
close_default_aws_server_bootstrap!()
36-
close_default_aws_client_bootstrap!()
37-
close_default_aws_host_resolver!()
38-
close_default_aws_event_loop_group!()
3930
end
4031
end
4132
catch e

src/server.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ function http_version(c::Connection)
4242
return v == AWS_HTTP_VERSION_2 ? "HTTP/2" : "HTTP/1.1"
4343
end
4444

45+
getinet(host::String, port::Integer) = Sockets.InetAddr(parse(IPAddr, host), port)
46+
getinet(host::IPAddr, port::Integer) = Sockets.InetAddr(host, port)
47+
4548
mutable struct Server{F, C}
4649
const f::F
4750
const on_stream_complete::C
@@ -105,10 +108,11 @@ function serve!(f, host="127.0.0.1", port=8080;
105108
ssl_alpn_list="h2;http/1.1",
106109
initial_window_size=typemax(UInt64),
107110
)
111+
addr = getinet(host, port)
108112
if listenany
109-
port, sock = Sockets.listenany(port)
110-
# don't need the socket server, so immediately close
111-
# (we were just looking for an open port)
113+
@show :pre port
114+
port, sock = Sockets.listenany(addr.host, addr.port)
115+
@show :post Int(port)
112116
close(sock)
113117
end
114118
server = Server{typeof(f), typeof(on_stream_complete)}(
@@ -120,6 +124,7 @@ function serve!(f, host="127.0.0.1", port=8080;
120124
socket_options !== nothing ? socket_options : aws_socket_options(
121125
AWS_SOCKET_STREAM, # socket type
122126
socket_domain == :ipv4 ? AWS_SOCKET_IPV4 : AWS_SOCKET_IPV6, # socket domain
127+
AWS_SOCKET_IMPL_PLATFORM_DEFAULT, # aws_socket_impl_type
123128
connect_timeout_ms,
124129
keep_alive_interval_sec,
125130
keep_alive_timeout_sec,

src/websockets.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module WebSockets
22

3-
using Base64, Random, LibAwsHTTP, LibAwsCommon, LibAwsIO
3+
using Base64, Random, LibAwsHTTPFork, LibAwsCommon, LibAwsIO
44

55
import ..FieldRef, ..iswss, ..getport, ..makeuri, ..aws_throw_error, ..resource, ..Headers, ..Header, ..str, ..aws_error, ..aws_throw_error, ..Future, ..parseuri, ..with_redirect, ..with_request, ..getclient, ..ClientSettings, ..scheme, ..host, ..getport, ..userinfo, ..Client, ..Request, ..Response, ..setinputstream!, ..getresponse, ..CookieJar, ..COOKIEJAR, ..addheaders, ..Stream, ..HTTP, ..getheader
66

0 commit comments

Comments
 (0)