Class: GoogleDrive::BasicFetcher
- Inherits:
-
Object
- Object
- GoogleDrive::BasicFetcher
- Defined in:
- lib/google_drive/basic_fetcher.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(proxy) ⇒ BasicFetcher
constructor
A new instance of BasicFetcher.
- #request_raw(method, url, data, extra_header, auth) ⇒ Object
Constructor Details
#initialize(proxy) ⇒ BasicFetcher
Returns a new instance of BasicFetcher.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/google_drive/basic_fetcher.rb', line 13 def initialize(proxy) if proxy @proxy = proxy elsif ENV["http_proxy"] && !ENV["http_proxy"].empty? proxy_url = URI.parse(ENV["http_proxy"]) @proxy = Net::HTTP.Proxy(proxy_url.host, proxy_url.port) else @proxy = Net::HTTP end end |
Instance Method Details
#request_raw(method, url, data, extra_header, auth) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/google_drive/basic_fetcher.rb', line 24 def request_raw(method, url, data, extra_header, auth) uri = URI.parse(url) http = @proxy.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # No timeout. It can take long e.g., when it tries to fetch a large file. http.read_timeout = nil http.start() do path = uri.path + (uri.query ? "?#{uri.query}" : "") header = auth_header(auth).merge(extra_header) if method == :delete || method == :get return http.__send__(method, path, header) else return http.__send__(method, path, data, header) end end end |