class Async::HTTP::WebMockEndpoint

def accept_socket(socket)

def accept_socket(socket)
  server = Async::HTTP::Server.new(WebMockApplication, self)
  server.accept(socket, socket.remote_address)
end

def alpn_protocol

def alpn_protocol
  nil # means HTTP11 will be used for HTTPS
end

def connect

def connect
  server_socket, client_socket = create_connected_sockets
  Async(transient: true) do
    accept_socket(server_socket)
  end
  client_socket
end

def create_connected_sockets

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

def initialize(scheme, authority, protocol)

def initialize(scheme, authority, protocol)
  @scheme = scheme
  @authority = authority
  @protocol = protocol
end

def inspect

def inspect
  "\#<#{self.class}> #{scheme}://#{authority} protocol=#{protocol}"
end

def socket_class

def socket_class
  defined?(Async::IO::Socket) ? Async::IO::Socket : Socket
end