15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/httparty/persistent/connection_adapter.rb', line 15
def build_persistent_http(uri, options)
opts = {:url => uri}
opts.merge!(options[:connection_adapter_options]) if options[:connection_adapter_options]
if options[:timeout] && (options[:timeout].is_a?(Integer) || options[:timeout].is_a?(Float))
opts.merge!(:read_timeout => options[:timeout], :open_timeout => options[:timeout])
end
opts.merge!(:debug_output => options[:debug_output]) if options[:debug_output]
if options[:http_proxyaddr]
proxy_opts = {:host => options[:http_proxyaddr]}
proxy_opts[:port] = options[:http_proxyport] if options[:http_proxyport]
opts[:proxy] = URI::HTTP.build(proxy_opts)
opts[:proxy].user = options[:http_proxyuser] if options[:http_proxyuser]
opts[:proxy].password = options[:http_proxypass] if options[:http_proxypass]
end
PersistentHTTP.new(opts)
end
|