Method: Sentry::HTTPTransport#conn

Defined in:
lib/sentry/transport/http_transport.rb

#connObject

[View source]

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/sentry/transport/http_transport.rb', line 89

def conn
  server = URI(@dsn.server)

  # connection respects proxy setting from @transport_configuration, or environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY)
  # Net::HTTP will automatically read the env vars.
  # See https://ruby-doc.org/3.2.2/stdlibs/net/Net/HTTP.html#class-Net::HTTP-label-Proxies
  connection =
    if proxy = normalize_proxy(@transport_configuration.proxy)
      ::Net::HTTP.new(server.hostname, server.port, proxy[:uri].hostname, proxy[:uri].port, proxy[:user], proxy[:password])
    else
      ::Net::HTTP.new(server.hostname, server.port)
    end

  connection.use_ssl = server.scheme == "https"
  connection.read_timeout = @transport_configuration.timeout
  connection.write_timeout = @transport_configuration.timeout if connection.respond_to?(:write_timeout)
  connection.open_timeout = @transport_configuration.open_timeout

  ssl_configuration.each do |key, value|
    connection.send("#{key}=", value)
  end

  connection
end