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 129
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 137
def connect
  server_socket, client_socket = create_connected_sockets
  Async 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 145
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 164
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 156
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 151
def create_connected_sockets
  Async::IO::Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM).tap do |sockets|
    sockets.each do |socket|
      socket.instance_variable_set :@alpn_protocol, @alpn_protocol
      socket.instance_eval do
        def alpn_protocol
          nil # means HTTP11 will be used for HTTPS
        end
      end
    end
  end
end