Method: HTTPX::UNIX#initialize

Defined in:
lib/httpx/io/unix.rb

#initialize(origin, addresses, options) ⇒ UNIX

Returns a new instance of UNIX.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/httpx/io/unix.rb', line 15

def initialize(origin, addresses, options)
  @addresses = addresses
  @hostname = origin.host
  @state = :idle
  @options = Options.new(options)
  @fallback_protocol = @options.fallback_protocol
  if @options.io
    @io = case @options.io
          when Hash
            @options.io[origin.authority]
          else
            @options.io
    end
    raise Error, "Given IO objects do not match the request authority" unless @io

    @path = @io.path
    @keep_open = true
    @state = :connected
  else
    if @options.transport_options
      # :nocov:
      warn ":transport_options is deprecated, use :addresses instead"
      @path = @options.transport_options[:path]
      # :nocov:
    else
      @path = addresses.first
    end
  end
  @io ||= build_socket
end