Method: HTTPX::Connection#initialize

Defined in:
lib/httpx/connection.rb

#initialize(uri, options) ⇒ Connection

Returns a new instance of Connection.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/httpx/connection.rb', line 47

def initialize(uri, options)
  @current_session = @current_selector =
    @parser = @sibling = @coalesced_connection = @altsvc_connection =
                           @family = @io = @ssl_session = @timeout =
                                             @connected_at = @response_received_at = nil

  @exhausted = @cloned = @main_sibling = false

  @options = Options.new(options)
  @type = initialize_type(uri, @options)
  @origins = [uri.origin]
  @origin = Utils.to_uri(uri.origin)
  @window_size = @options.window_size
  @read_buffer = Buffer.new(@options.buffer_size)
  @write_buffer = Buffer.new(@options.buffer_size)
  @pending = []
  @inflight = 0
  @keep_alive_timeout = @options.timeout[:keep_alive_timeout]

  if @options.io
    # if there's an already open IO, get its
    # peer address, and force-initiate the parser
    transition(:already_open)
    @io = build_socket
    parser
  else
    transition(:idle)
  end
  self.addresses = @options.addresses if @options.addresses
end