Sha256: 21a5e537546e3fd693ccf971345fe91ec2f793fca85d697e706ec6e3ba3925a3
Contents?: true
Size: 1.39 KB
Versions: 11
Compression:
Stored size: 1.39 KB
Contents
require 'open-uri' require 'uri' module HttpUtilities module Http module Adapters module OpenUri def retrieve_open_uri_content(url, options = {}, retries = 0, max_retries = 3) response = nil options = options.clone() request = HttpUtilities::Http::Request.new request.set_proxy_options(options) open_uri_options = {"UserAgent" => request.user_agent} open_uri_options[:read_timeout] = options.delete(:timeout) { |e| 120 } if (request.proxy[:host] && request.proxy[:port]) proxy_address = Proxy.format_proxy_address(request.proxy[:host], request.proxy[:port], true) open_uri_options[:proxy] = proxy_address if (request.proxy[:username] && request.proxy[:password]) open_uri_options[:proxy_http_basic_authentication] = [proxy_address, request.proxy[:username], request.proxy[:password]] end end connection = nil while (connection.nil? && retries < max_retries) connection = open(url, open_uri_options) retries += 1 end if (connection) connection.rewind response = connection.readlines.join("\n") response = HttpUtilities::Http::Response.new(response, request) end return response end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems