4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/postageapp/http.rb', line 4
def self.connect(config)
connector =
if (config.proxy?)
Net::HTTP::Proxy(
config.proxy_host,
config.proxy_port || SOCKS5_PORT_DEFAULT,
config.proxy_user,
config.proxy_pass
)
else
Net::HTTP
end
http = connector.new(config.host, config.port)
unless (config.verify_certificate?)
context = OpenSSL::SSL::SSLContext.new
context.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.send(:instance_variable_set, :@ssl_context, context)
end
http.read_timeout = config.http_read_timeout
http.open_timeout = config.http_open_timeout
http.use_ssl = config.secure?
http
end
|