@@ -11,6 +11,7 @@ using JSON
11
11
using Test
12
12
using URIs
13
13
using InteractiveUtils: @which
14
+ using ConcurrentUtilities
14
15
15
16
# test we can adjust default_connection_limit
16
17
for x in (10 , 12 )
323
324
HTTP. get (" http://$httpbin /delay/1" ; readtimeout= 2 , retry= false )
324
325
end
325
326
327
+ @testset " connect_timeout does not include the time needed to acquire a connection from the pool" begin
328
+ connection_limit = HTTP. Connections. TCP_POOL[]. max
329
+ try
330
+ dummy_conn = HTTP. Connection (Sockets. TCPSocket ())
331
+ HTTP. set_default_connection_limit! (1 )
332
+ @assert HTTP. Connections. TCP_POOL[]. max == 1
333
+ # drain the pool
334
+ acquire (()-> dummy_conn, HTTP. Connections. TCP_POOL[], HTTP. Connections. connectionkey (dummy_conn))
335
+ # Put it back in 10 seconds
336
+ Timer (t-> HTTP. Connections. releaseconnection (dummy_conn, false ), 10 ; interval= 0 )
337
+ # If we count the time it takes to acquire the connection from the pool, we'll get a timeout error.
338
+ HTTP. get (" https://$httpbin /get" ; connection_timeout= 5 , retry= false , socket_type_tls= Sockets. TCPSocket)
339
+ @test true # if we get here, we didn't timeout
340
+ finally
341
+ HTTP. set_default_connection_limit! (connection_limit)
342
+ end
343
+ end
344
+
326
345
@testset " Retry all resolved IP addresses" begin
327
346
# See issue https://github.com/JuliaWeb/HTTP.jl/issues/672
328
347
# Bit tricky to test, but can at least be tested if localhost
0 commit comments