From 39a4c5cbc95eebf0ed2507f398390bb67562ba9f Mon Sep 17 00:00:00 2001 From: Jake Frautschi Date: Fri, 26 Apr 2024 14:32:57 -0700 Subject: [PATCH 1/5] Replace Async::IO::Socket usage with stdlib Socket for async-http adapter to remove implicit dependency on async-io --- lib/webmock/http_lib_adapters/async_http_client_adapter.rb | 4 ++-- .../async_http_client/async_http_client_spec_helper.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index db30ab93..cefaaab4 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -154,9 +154,9 @@ def inspect def create_connected_sockets pair = begin - Async::IO::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) + Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) rescue Errno::EAFNOSUPPORT - Async::IO::Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM) + Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM) end pair.tap do |sockets| sockets.each do |socket| diff --git a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb index d76b6ea3..f6f3a23c 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb @@ -1,3 +1,5 @@ +require "ostruct" + module AsyncHttpClientSpecHelper def http_request(method, url, options = {}, &block) endpoint = Async::HTTP::Endpoint.parse(url) From 001f15f57231a2b0fbcfd42f1a90ee827db1c874 Mon Sep 17 00:00:00 2001 From: Jake Frautschi Date: Fri, 26 Apr 2024 14:38:10 -0700 Subject: [PATCH 2/5] Use single-quotes --- .../async_http_client/async_http_client_spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb index f6f3a23c..bed7b457 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb @@ -1,4 +1,4 @@ -require "ostruct" +require 'ostruct' module AsyncHttpClientSpecHelper def http_request(method, url, options = {}, &block) From 83b6ec7473df52e2bcd1e8d40aac3fd636c4034e Mon Sep 17 00:00:00 2001 From: Art Rybalko Date: Mon, 29 Apr 2024 15:47:01 +0300 Subject: [PATCH 3/5] Update version.rb --- lib/webmock/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webmock/version.rb b/lib/webmock/version.rb index ba520a1a..acac3b18 100644 --- a/lib/webmock/version.rb +++ b/lib/webmock/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module WebMock - VERSION = '3.23.0' unless defined?(::WebMock::VERSION) + VERSION = '3.23.1' unless defined?(::WebMock::VERSION) end From 54519b2311a83d768f8d9f65afd2be4802b78ed0 Mon Sep 17 00:00:00 2001 From: Jake Frautschi Date: Wed, 22 May 2024 16:38:49 -0700 Subject: [PATCH 4/5] Use Async::Socket if is present --- .../http_lib_adapters/async_http_client_adapter.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index cefaaab4..c1b9e81b 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -152,11 +152,15 @@ def inspect private + def socket_class + @_socket_class ||= Gem::Dependency.new("async-io").matching_specs.any? ? Async::IO::Socket : Socket + end + def create_connected_sockets pair = begin - Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) + socket_class.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) rescue Errno::EAFNOSUPPORT - Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM) + socket_class.pair(Socket::AF_INET, Socket::SOCK_STREAM) end pair.tap do |sockets| sockets.each do |socket| From 6cbfed01f0ce86b92af246f99a23168960189d20 Mon Sep 17 00:00:00 2001 From: Jake Frautschi Date: Wed, 22 May 2024 16:46:22 -0700 Subject: [PATCH 5/5] Much simpler --- lib/webmock/http_lib_adapters/async_http_client_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index c1b9e81b..65910901 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -153,7 +153,7 @@ def inspect private def socket_class - @_socket_class ||= Gem::Dependency.new("async-io").matching_specs.any? ? Async::IO::Socket : Socket + defined?(Async::IO::Socket) ? Async::IO::Socket : Socket end def create_connected_sockets