From fb578ea146da03bd10343123504f159b83870842 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 23 Apr 2024 14:31:54 +1200 Subject: [PATCH 1/2] Use `io-stream` for buffered streams. --- async-http.gemspec | 3 ++- fixtures/async/http/a_protocol.rb | 7 ++++++- gems.rb | 1 + lib/async/http/body/pipe.rb | 9 +++------ lib/async/http/protocol/http1.rb | 8 +++++--- lib/async/http/protocol/http1/connection.rb | 2 +- lib/async/http/protocol/http10.rb | 6 +++--- lib/async/http/protocol/http11.rb | 6 +++--- lib/async/http/protocol/http2.rb | 10 +++++----- lib/async/http/protocol/http2/connection.rb | 2 +- test/async/http/body/pipe.rb | 2 +- test/async/http/proxy.rb | 22 ++++++++++----------- 12 files changed, 41 insertions(+), 37 deletions(-) diff --git a/async-http.gemspec b/async-http.gemspec index 22c99209..5bba293a 100644 --- a/async-http.gemspec +++ b/async-http.gemspec @@ -25,8 +25,9 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 3.1" spec.add_dependency "async", ">= 1.25" - spec.add_dependency "async-io", ">= 1.28" + spec.add_dependency "async-io", ">= 1.43.1" spec.add_dependency "async-pool", ">= 0.6.1" + spec.add_dependency "io-stream", "~> 0.1.1" spec.add_dependency "protocol-http", "~> 0.26.0" spec.add_dependency "protocol-http1", "~> 0.19.0" spec.add_dependency "protocol-http2", "~> 0.17.0" diff --git a/fixtures/async/http/a_protocol.rb b/fixtures/async/http/a_protocol.rb index f584bd72..4250c438 100644 --- a/fixtures/async/http/a_protocol.rb +++ b/fixtures/async/http/a_protocol.rb @@ -202,6 +202,9 @@ module HTTP end it "disconnects slow clients" do + # We won't be able to disconnect slow clients if IO#timeout is not available: + skip_unless_method_defined(:timeout, IO) + response = client.get("/") response.read @@ -478,9 +481,11 @@ def after end it "can't get /" do + skip_unless_method_defined(:timeout, IO) + expect do client.get("/") - end.to raise_exception(Async::TimeoutError) + end.to raise_exception(::IO::TimeoutError) end end diff --git a/gems.rb b/gems.rb index 2173f993..624f8238 100644 --- a/gems.rb +++ b/gems.rb @@ -9,6 +9,7 @@ # gem "async", path: "../async" # gem "async-io", path: "../async-io" +# gem "io-stream", path: "../io-stream" # gem "traces", path: "../traces" # gem "protocol-http", path: "../protocol-http" diff --git a/lib/async/http/body/pipe.rb b/lib/async/http/body/pipe.rb index 7cae7a1e..6ef1c0e1 100644 --- a/lib/async/http/body/pipe.rb +++ b/lib/async/http/body/pipe.rb @@ -1,12 +1,9 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2023, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Bruno Sutic. -require 'async/io/socket' -require 'async/io/stream' - require_relative 'writable' module Async @@ -18,9 +15,9 @@ def initialize(input, output = Writable.new, task: Task.current) @input = input @output = output - head, tail = IO::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) + head, tail = ::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) - @head = IO::Stream.new(head) + @head = ::IO::Stream::Buffered.new(head) @tail = tail @reader = nil diff --git a/lib/async/http/protocol/http1.rb b/lib/async/http/protocol/http1.rb index cd810519..e30f3410 100644 --- a/lib/async/http/protocol/http1.rb +++ b/lib/async/http/protocol/http1.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2017-2023, by Samuel Williams. +# Copyright, 2017-2024, by Samuel Williams. require_relative 'http1/client' require_relative 'http1/server' +require 'io/stream/buffered' + module Async module HTTP module Protocol @@ -21,13 +23,13 @@ def self.trailer? end def self.client(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Client.new(stream, VERSION) end def self.server(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Server.new(stream, VERSION) end diff --git a/lib/async/http/protocol/http1/connection.rb b/lib/async/http/protocol/http1/connection.rb index fb8491bb..23a3ed6f 100755 --- a/lib/async/http/protocol/http1/connection.rb +++ b/lib/async/http/protocol/http1/connection.rb @@ -62,7 +62,7 @@ def concurrency # Can we use this connection to make requests? def viable? - @ready && @stream&.connected? + @ready && @stream&.readable? end def reusable? diff --git a/lib/async/http/protocol/http10.rb b/lib/async/http/protocol/http10.rb index 0d1be183..9066d693 100755 --- a/lib/async/http/protocol/http10.rb +++ b/lib/async/http/protocol/http10.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2017-2023, by Samuel Williams. +# Copyright, 2017-2024, by Samuel Williams. require_relative 'http1' @@ -20,13 +20,13 @@ def self.trailer? end def self.client(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Client.new(stream, VERSION) end def self.server(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Server.new(stream, VERSION) end diff --git a/lib/async/http/protocol/http11.rb b/lib/async/http/protocol/http11.rb index ef929b48..083dc141 100644 --- a/lib/async/http/protocol/http11.rb +++ b/lib/async/http/protocol/http11.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2017-2023, by Samuel Williams. +# Copyright, 2017-2024, by Samuel Williams. # Copyright, 2018, by Janko Marohnić. require_relative 'http1' @@ -21,13 +21,13 @@ def self.trailer? end def self.client(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Client.new(stream, VERSION) end def self.server(peer) - stream = IO::Stream.new(peer, sync: true) + stream = ::IO::Stream::Buffered.wrap(peer) return HTTP1::Server.new(stream, VERSION) end diff --git a/lib/async/http/protocol/http2.rb b/lib/async/http/protocol/http2.rb index 6671f8ee..7a75a34a 100644 --- a/lib/async/http/protocol/http2.rb +++ b/lib/async/http/protocol/http2.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2018-2023, by Samuel Williams. +# Copyright, 2018-2024, by Samuel Williams. require_relative 'http2/client' require_relative 'http2/server' +require 'io/stream/buffered' + module Async module HTTP module Protocol @@ -35,8 +37,7 @@ def self.trailer? } def self.client(peer, settings = CLIENT_SETTINGS) - stream = IO::Stream.new(peer, sync: true) - + stream = ::IO::Stream::Buffered.wrap(peer) client = Client.new(stream) client.send_connection_preface(settings) @@ -46,8 +47,7 @@ def self.client(peer, settings = CLIENT_SETTINGS) end def self.server(peer, settings = SERVER_SETTINGS) - stream = IO::Stream.new(peer, sync: true) - + stream = ::IO::Stream::Buffered.wrap(peer) server = Server.new(stream) server.read_connection_preface(settings) diff --git a/lib/async/http/protocol/http2/connection.rb b/lib/async/http/protocol/http2/connection.rb index d63cb924..631cc416 100644 --- a/lib/async/http/protocol/http2/connection.rb +++ b/lib/async/http/protocol/http2/connection.rb @@ -122,7 +122,7 @@ def concurrency # Can we use this connection to make requests? def viable? - @stream.connected? + @stream&.readable? end def reusable? diff --git a/test/async/http/body/pipe.rb b/test/async/http/body/pipe.rb index 8efac033..94cdcb07 100644 --- a/test/async/http/body/pipe.rb +++ b/test/async/http/body/pipe.rb @@ -42,7 +42,7 @@ def aftrer end it "returns an io socket" do - expect(io).to be_a(Async::IO::Socket) + expect(io).to be_a(::Socket) expect(io.read).to be == data end diff --git a/test/async/http/proxy.rb b/test/async/http/proxy.rb index 689c5c5a..4575863d 100644 --- a/test/async/http/proxy.rb +++ b/test/async/http/proxy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2023, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Sam Shadwell. require 'async' @@ -86,12 +86,10 @@ expect(proxy.client.pool).to be(:empty?) proxy.connect do |peer| - stream = Async::IO::Stream.new(peer) + peer.write(data) + peer.close_write - stream.write(data) - stream.close_write - - expect(stream.read).to be == data + expect(peer.read).to be == data end proxy.close @@ -102,14 +100,14 @@ proxy = Async::HTTP::Proxy.tcp(client, "localhost", 1) expect(proxy.client.pool).to be(:empty?) - stream = Async::IO::Stream.new(proxy.connect) + peer = proxy.connect - stream.write(data) - stream.close_write + peer.write(data) + peer.close_write - expect(stream.read).to be == data + expect(peer.read).to be == data - stream.close + peer.close proxy.close expect(proxy.client.pool).to be(:empty?) @@ -131,7 +129,7 @@ Console.logger.debug(self) {"Making connection to #{endpoint}..."} Async::HTTP::Body::Hijack.response(request, 200, {}) do |stream| - upstream = Async::IO::Stream.new(endpoint.connect) + upstream = ::IO::Stream::Buffered.wrap(endpoint.connect) Console.logger.debug(self) {"Connected to #{upstream}..."} reader = Async do |task| From 0c4e6c5943fac7057dd5f47b19f0c14eda9dd87f Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 23 Apr 2024 16:50:05 +1200 Subject: [PATCH 2/2] Replace `Async::IO::Endpoint` with `IO::Endpoint`. --- async-http.gemspec | 6 +-- bake/async/http/h2spec.rb | 6 +-- config/external.yaml | 2 +- examples/google/codeotaku.rb | 4 +- examples/google/search.rb | 4 +- fixtures/async/http/a_protocol.rb | 51 +++++++++------------ gems.rb | 7 ++- lib/async/http/client.rb | 8 ++-- lib/async/http/endpoint.rb | 13 +++--- lib/async/http/protocol/http1/request.rb | 4 +- lib/async/http/protocol/http2/connection.rb | 13 +++--- lib/async/http/proxy.rb | 4 +- lib/async/http/server.rb | 3 +- test/async/http/body.rb | 7 +-- test/async/http/endpoint.rb | 6 +-- test/async/http/proxy.rb | 2 +- test/async/http/ssl.rb | 8 ++-- 17 files changed, 68 insertions(+), 80 deletions(-) diff --git a/async-http.gemspec b/async-http.gemspec index 5bba293a..da7108ce 100644 --- a/async-http.gemspec +++ b/async-http.gemspec @@ -24,10 +24,10 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 3.1" - spec.add_dependency "async", ">= 1.25" - spec.add_dependency "async-io", ">= 1.43.1" + spec.add_dependency "async", ">= 2.10.2" spec.add_dependency "async-pool", ">= 0.6.1" - spec.add_dependency "io-stream", "~> 0.1.1" + spec.add_dependency "io-endpoint", "~> 0.10.0" + spec.add_dependency "io-stream", "~> 0.3.0" spec.add_dependency "protocol-http", "~> 0.26.0" spec.add_dependency "protocol-http1", "~> 0.19.0" spec.add_dependency "protocol-http2", "~> 0.17.0" diff --git a/bake/async/http/h2spec.rb b/bake/async/http/h2spec.rb index dd57415f..7807c854 100644 --- a/bake/async/http/h2spec.rb +++ b/bake/async/http/h2spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2023, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. def build # Fetch the code: @@ -24,9 +24,9 @@ def server require 'async' require 'async/container' require 'async/http/server' - require 'async/io/host_endpoint' + require 'io/endpoint/host_endpoint' - endpoint = Async::IO::Endpoint.tcp('127.0.0.1', 7272) + endpoint = IO::Endpoint.tcp('127.0.0.1', 7272) container = Async::Container.new diff --git a/config/external.yaml b/config/external.yaml index 8cc0f3a1..b5d9764d 100644 --- a/config/external.yaml +++ b/config/external.yaml @@ -9,7 +9,7 @@ async-websocket: command: bundle exec sus async-http-faraday: url: https://github.com/socketry/async-http-faraday.git - command: bundle exec rspec + command: bundle exec bake test # async-http-cache: # url: https://github.com/socketry/async-http-cache.git # command: bundle exec rspec diff --git a/examples/google/codeotaku.rb b/examples/google/codeotaku.rb index 7f19d756..fcffc799 100755 --- a/examples/google/codeotaku.rb +++ b/examples/google/codeotaku.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2020-2023, by Samuel Williams. +# Copyright, 2020-2024, by Samuel Williams. require "async" require "async/clock" @@ -12,8 +12,6 @@ URL = "https://www.codeotaku.com/index" ENDPOINT = Async::HTTP::Endpoint.parse(URL) -Console.logger.enable(Async::IO::Stream, Console::Logger::DEBUG) - if count = ENV['COUNT']&.to_i terms = terms.first(count) end diff --git a/examples/google/search.rb b/examples/google/search.rb index a9c331d0..353199ed 100755 --- a/examples/google/search.rb +++ b/examples/google/search.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2023, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. require "async" require "async/clock" @@ -12,8 +12,6 @@ URL = "https://www.google.com/search" ENDPOINT = Async::HTTP::Endpoint.parse(URL) -# Console.logger.enable(Async::IO::Stream, Console::Logger::DEBUG) - class Google < Protocol::HTTP::Middleware def search(term) Console.logger.info(self) {"Searching for #{term}..."} diff --git a/fixtures/async/http/a_protocol.rb b/fixtures/async/http/a_protocol.rb index 4250c438..82e0e1fc 100644 --- a/fixtures/async/http/a_protocol.rb +++ b/fixtures/async/http/a_protocol.rb @@ -202,9 +202,6 @@ module HTTP end it "disconnects slow clients" do - # We won't be able to disconnect slow clients if IO#timeout is not available: - skip_unless_method_defined(:timeout, IO) - response = client.get("/") response.read @@ -481,8 +478,6 @@ def after end it "can't get /" do - skip_unless_method_defined(:timeout, IO) - expect do client.get("/") end.to raise_exception(::IO::TimeoutError) @@ -536,47 +531,45 @@ def after end end - def around - current = Console.logger.level - Console.logger.fatal! - - super - ensure - Console.logger.level = current - end - it "doesn't cancel all requests" do - tasks = [] task = Async::Task.current + tasks = [] stopped = [] 10.times do - tasks << task.async { - begin - loop do - client.get('http://127.0.0.1:8080/a').finish - end + task.async do |child| + tasks << child + + loop do + response = client.get('/a') + response.finish ensure - stopped << 'a' + response&.close end - } + ensure + stopped << 'a' + end end 10.times do - tasks << task.async { - begin - loop do - client.get('http://127.0.0.1:8080/b').finish - end + task.async do |child| + tasks << child + + loop do + response = client.get('/b') + response.finish ensure - stopped << 'b' + response&.close end - } + ensure + stopped << 'b' + end end tasks.each do |child| sleep 0.01 child.stop + child.wait end expect(stopped.sort).to be == stopped diff --git a/gems.rb b/gems.rb index 624f8238..e54c007a 100644 --- a/gems.rb +++ b/gems.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2017-2023, by Samuel Williams. +# Copyright, 2017-2024, by Samuel Williams. source 'https://rubygems.org' @@ -9,8 +9,11 @@ # gem "async", path: "../async" # gem "async-io", path: "../async-io" +# gem "io-endpoint", path: "../io-endpoint" # gem "io-stream", path: "../io-stream" +# gem "openssl", git: "https://github.com/ruby/openssl.git" # gem "traces", path: "../traces" +# gem "sus-fixtures-async-http", path: "../sus-fixtures-async-http" # gem "protocol-http", path: "../protocol-http" # gem "protocol-http1", path: "../protocol-http1" @@ -29,7 +32,7 @@ gem "covered" gem "sus" gem "sus-fixtures-async" - gem "sus-fixtures-async-http", "~> 0.7" + gem "sus-fixtures-async-http", "~> 0.8" gem "sus-fixtures-openssl" gem "bake" diff --git a/lib/async/http/client.rb b/lib/async/http/client.rb index 5783669d..58ebfc28 100755 --- a/lib/async/http/client.rb +++ b/lib/async/http/client.rb @@ -4,8 +4,7 @@ # Copyright, 2017-2024, by Samuel Williams. # Copyright, 2022, by Ian Ker-Seymer. -require 'async/io/endpoint' -require 'async/io/stream' +require 'io/endpoint' require 'async/pool/controller' @@ -107,7 +106,6 @@ def call(request) # This signals that the ensure block below should not try to release the connection, because it's bound into the response which will be returned: connection = nil - return response rescue Protocol::RequestFailed # This is a specific case where the entire request wasn't sent before a failure occurred. So, we can even resend non-idempotent requests. @@ -133,7 +131,9 @@ def call(request) raise end ensure - @pool.release(connection) if connection + if connection + @pool.release(connection) + end end end diff --git a/lib/async/http/endpoint.rb b/lib/async/http/endpoint.rb index 88c85dbe..995d2f9e 100644 --- a/lib/async/http/endpoint.rb +++ b/lib/async/http/endpoint.rb @@ -4,10 +4,9 @@ # Copyright, 2019-2024, by Samuel Williams. # Copyright, 2021-2022, by Adam Daniels. -require 'async/io/host_endpoint' -require 'async/io/ssl_endpoint' -require 'async/io/ssl_socket' -require 'async/io/shared_endpoint' +require 'io/endpoint' +require 'io/endpoint/host_endpoint' +require 'io/endpoint/ssl_endpoint' require_relative 'protocol/http1' require_relative 'protocol/https' @@ -15,7 +14,7 @@ module Async module HTTP # Represents a way to connect to a remote HTTP server. - class Endpoint < Async::IO::Endpoint + class Endpoint < ::IO::Endpoint::Generic def self.parse(string, endpoint = nil, **options) url = URI.parse(string).normalize @@ -164,7 +163,7 @@ def build_endpoint(endpoint = nil) if secure? # Wrap it in SSL: - return Async::IO::SSLEndpoint.new(endpoint, + return ::IO::Endpoint::SSLEndpoint.new(endpoint, ssl_context: self.ssl_context, hostname: @url.hostname, timeout: self.timeout, @@ -226,7 +225,7 @@ def tcp_options end def tcp_endpoint - Async::IO::Endpoint.tcp(self.hostname, port, **tcp_options) + ::IO::Endpoint.tcp(self.hostname, port, **tcp_options) end end end diff --git a/lib/async/http/protocol/http1/request.rb b/lib/async/http/protocol/http1/request.rb index 37d5c8b3..3e129c63 100644 --- a/lib/async/http/protocol/http1/request.rb +++ b/lib/async/http/protocol/http1/request.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2018-2023, by Samuel Williams. +# Copyright, 2018-2024, by Samuel Williams. require_relative '../request' @@ -15,7 +15,7 @@ def self.read(connection) self.new(connection, *parts) end end - + UPGRADE = 'upgrade' def initialize(connection, authority, method, path, version, headers, body) diff --git a/lib/async/http/protocol/http2/connection.rb b/lib/async/http/protocol/http2/connection.rb index 631cc416..ccf931e7 100644 --- a/lib/async/http/protocol/http2/connection.rb +++ b/lib/async/http/protocol/http2/connection.rb @@ -90,19 +90,18 @@ def read_in_background(parent: Task.current) self.consume_window self.read_frame end - rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled - # Ignore. - rescue ::Protocol::HTTP2::GoawayError => error + rescue Async::Stop, ::IO::TimeoutError, ::Protocol::HTTP2::GoawayError => error # Error is raised if a response is actively reading from the # connection. The connection is silently closed if GOAWAY is # received outside the request/response cycle. - if @reader - self.close(error) - end + rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE => ignored_error + # Ignore. + rescue => error + # Every other error. ensure # Don't call #close twice. if @reader - self.close($!) + self.close(error) end end end diff --git a/lib/async/http/proxy.rb b/lib/async/http/proxy.rb index c053d86a..338031b1 100644 --- a/lib/async/http/proxy.rb +++ b/lib/async/http/proxy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2023, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. require_relative 'client' require_relative 'endpoint' @@ -46,7 +46,7 @@ def proxied_endpoint(endpoint, headers = nil) # @param host [String] the hostname or address to connect to. # @param port [String] the port number to connect to. # @param headers [Array] an optional list of headers to use when establishing the connection. - # @see Async::IO::Endpoint#tcp + # @see IO::Endpoint#tcp def self.tcp(client, host, port, headers = nil) self.new(client, "#{host}:#{port}", headers) end diff --git a/lib/async/http/server.rb b/lib/async/http/server.rb index 1f60a340..b7cde942 100755 --- a/lib/async/http/server.rb +++ b/lib/async/http/server.rb @@ -4,8 +4,7 @@ # Copyright, 2017-2024, by Samuel Williams. # Copyright, 2019, by Brian Morearty. -require 'async/io/endpoint' -require 'async/io/stream' +require 'io/endpoint' require 'protocol/http/middleware' diff --git a/test/async/http/body.rb b/test/async/http/body.rb index e08ad660..37d5adb8 100644 --- a/test/async/http/body.rb +++ b/test/async/http/body.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2018-2023, by Samuel Williams. +# Copyright, 2018-2024, by Samuel Williams. require 'async/http/body' @@ -9,6 +9,7 @@ require 'sus/fixtures/openssl' require 'sus/fixtures/async/http' require 'localhost/authority' +require 'io/endpoint/ssl_endpoint' ABody = Sus::Shared("a body") do with 'echo server' do @@ -97,11 +98,11 @@ let(:client_context) {authority.client_context} def make_server_endpoint(bound_endpoint) - Async::IO::SSLEndpoint.new(super, ssl_context: server_context) + ::IO::Endpoint::SSLEndpoint.new(super, ssl_context: server_context) end def make_client_endpoint(bound_endpoint) - Async::IO::SSLEndpoint.new(super, ssl_context: client_context) + ::IO::Endpoint::SSLEndpoint.new(super, ssl_context: client_context) end it_behaves_like ABody diff --git a/test/async/http/endpoint.rb b/test/async/http/endpoint.rb index d14b1464..e04169bd 100644 --- a/test/async/http/endpoint.rb +++ b/test/async/http/endpoint.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2018-2023, by Samuel Williams. +# Copyright, 2018-2024, by Samuel Williams. # Copyright, 2021-2022, by Adam Daniels. require 'async/http/endpoint' @@ -36,7 +36,7 @@ end it "should be connecting to 127.0.0.1" do - expect(subject.endpoint).to be_a Async::IO::SSLEndpoint + expect(subject.endpoint).to be_a ::IO::Endpoint::SSLEndpoint expect(subject.endpoint).to have_attributes(hostname: be == '127.0.0.1') expect(subject.endpoint.endpoint).to have_attributes(hostname: be == '127.0.0.1') end @@ -49,7 +49,7 @@ end it "should be connecting to localhost" do - expect(subject.endpoint).to be_a Async::IO::SSLEndpoint + expect(subject.endpoint).to be_a ::IO::Endpoint::SSLEndpoint expect(subject.endpoint).to have_attributes(hostname: be == '127.0.0.1') expect(subject.endpoint.endpoint).to have_attributes(hostname: be == 'localhost') end diff --git a/test/async/http/proxy.rb b/test/async/http/proxy.rb index 4575863d..b3b4708e 100644 --- a/test/async/http/proxy.rb +++ b/test/async/http/proxy.rb @@ -124,7 +124,7 @@ end host, port = request.path.split(":", 2) - endpoint = Async::IO::Endpoint.tcp(host, port) + endpoint = IO::Endpoint.tcp(host, port) Console.logger.debug(self) {"Making connection to #{endpoint}..."} diff --git a/test/async/http/ssl.rb b/test/async/http/ssl.rb index 54ccb70c..6751e632 100644 --- a/test/async/http/ssl.rb +++ b/test/async/http/ssl.rb @@ -1,14 +1,12 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2018-2023, by Samuel Williams. +# Copyright, 2018-2024, by Samuel Williams. require 'async/http/server' require 'async/http/client' require 'async/http/endpoint' -require 'async/io/ssl_socket' - require 'sus/fixtures/async' require 'sus/fixtures/openssl' require 'sus/fixtures/async/http' @@ -41,11 +39,11 @@ end def make_server_endpoint(bound_endpoint) - Async::IO::SSLEndpoint.new(super, ssl_context: server_context) + ::IO::Endpoint::SSLEndpoint.new(super, ssl_context: server_context) end def make_client_endpoint(bound_endpoint) - Async::IO::SSLEndpoint.new(super, ssl_context: client_context) + ::IO::Endpoint::SSLEndpoint.new(super, ssl_context: client_context) end it "client can get a resource via https" do