Method: Gem::Net::HTTP#initialize

Defined in:
lib/rubygems/vendor/net-http/lib/net/http.rb

#initialize(address, port = nil) ⇒ HTTP

Creates a new Gem::Net::HTTP object for the specified server address, without opening the TCP connection or initializing the HTTP session. The address should be a DNS hostname or IP address.



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
# File 'lib/rubygems/vendor/net-http/lib/net/http.rb', line 1154

def initialize(address, port = nil) # :nodoc:
  defaults = {
    keep_alive_timeout: 2,
    close_on_empty_response: false,
    open_timeout: 60,
    read_timeout: 60,
    write_timeout: 60,
    continue_timeout: nil,
    max_retries: 1,
    debug_output: nil,
    response_body_encoding: false,
    ignore_eof: true
  }
  options = defaults.merge(self.class.default_configuration || {})

  @address = address
  @port    = (port || HTTP.default_port)
  @ipaddr = nil
  @local_host = nil
  @local_port = nil
  @curr_http_version = HTTPVersion
  @keep_alive_timeout = options[:keep_alive_timeout]
  @last_communicated = nil
  @close_on_empty_response = options[:close_on_empty_response]
  @socket  = nil
  @started = false
  @open_timeout = options[:open_timeout]
  @read_timeout = options[:read_timeout]
  @write_timeout = options[:write_timeout]
  @continue_timeout = options[:continue_timeout]
  @max_retries = options[:max_retries]
  @debug_output = options[:debug_output]
  @response_body_encoding = options[:response_body_encoding]
  @ignore_eof = options[:ignore_eof]

  @proxy_from_env = false
  @proxy_uri      = nil
  @proxy_address  = nil
  @proxy_port     = nil
  @proxy_user     = nil
  @proxy_pass     = nil
  @proxy_use_ssl  = nil

  @use_ssl = false
  @ssl_context = nil
  @ssl_session = nil
  @sspi_enabled = false
  SSL_IVNAMES.each do |ivname|
    instance_variable_set ivname, nil
  end
end