class Async::HTTP::WebMockEndpoint

Attributes

scheme[RW]

Public Class Methods

new(scheme, authority, protocol) click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 134
def initialize(scheme, authority, protocol)
  @scheme = scheme
  @authority = authority
  @protocol = protocol
end

Public Instance Methods

connect() click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 142
def connect
  server_socket, client_socket = create_connected_sockets
  Async(transient: true) do
    accept_socket(server_socket)
  end
  client_socket
end
inspect() click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 150
def inspect
  "\#<#{self.class}> #{scheme}://#{authority} protocol=#{protocol}"
end

Private Instance Methods

accept_socket(socket) click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 178
def accept_socket(socket)
  server = Async::HTTP::Server.new(WebMockApplication, self)
  server.accept(socket, socket.remote_address)
end
alpn_protocol() click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 170
def alpn_protocol
  nil # means HTTP11 will be used for HTTPS
end
create_connected_sockets() click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 160
def create_connected_sockets
  pair = begin
    socket_class.pair(Socket::AF_UNIX, Socket::SOCK_STREAM)
  rescue Errno::EAFNOSUPPORT
    socket_class.pair(Socket::AF_INET, Socket::SOCK_STREAM)
  end
  pair.tap do |sockets|
    sockets.each do |socket|
      socket.instance_variable_set :@alpn_protocol, nil
      socket.instance_eval do
        def alpn_protocol
          nil # means HTTP11 will be used for HTTPS
        end
      end
    end
  end
end
socket_class() click to toggle source
# File lib/webmock/http_lib_adapters/async_http_client_adapter.rb, line 156
def socket_class
  defined?(Async::IO::Socket) ? Async::IO::Socket : Socket
end