Method: OpenC3::HttpClientInterface#connect

Defined in:
lib/openc3/interfaces/http_client_interface.rb

#connectObject

Connects the interface to its target(s)



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openc3/interfaces/http_client_interface.rb', line 53

def connect
  # Per https://github.com/lostisland/faraday/blob/main/lib/faraday/options/env.rb
  # :timeout       - time limit for the entire request (Integer in seconds)
  # :open_timeout  - time limit for just the connection phase (e.g. handshake) (Integer in seconds)
  # :read_timeout  - time limit for the first response byte received from the server (Integer in seconds)
  # :write_timeout - time limit for the client to send the request to the server (Integer in seconds)
  request = {}
  request['open_timeout'] = @connect_timeout if @connect_timeout
  request['read_timeout'] = @read_timeout if @read_timeout
  request['write_timeout'] = @write_timeout if @write_timeout
  @http = Faraday.new(request: request) do |f|
    f.response :follow_redirects # use Faraday::FollowRedirects::Middleware
    f.adapter :net_http # adds the adapter to the connection, defaults to `Faraday.default_adapter`
  end
  super()
end