mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-05 00:02:38 -04:00
the previous patch allowed the callback to be called only once, whereas this one will be long-lived for the duration of the connection
31 lines
576 B
Ruby
31 lines
576 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
require "support/http_helpers"
|
|
|
|
class Bug_1_1_1_Test < Minitest::Test
|
|
include HTTPHelpers
|
|
|
|
def test_conection_callbacks_fire_setup_once
|
|
uri = build_uri("/get")
|
|
|
|
connected = 0
|
|
|
|
HTTPX.on_connection_opened { |*| connected += 1 }
|
|
.on_connection_closed { |*| connected -= 1 }
|
|
.wrap do |session|
|
|
3.times.each do
|
|
response = session.get(uri)
|
|
verify_status(response, 200)
|
|
assert connected.zero?
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def scheme
|
|
"http://"
|
|
end
|
|
end
|