Class: GoogleDrive::ClientLoginFetcher
- Inherits:
-
Object
- Object
- GoogleDrive::ClientLoginFetcher
- Defined in:
- lib/google_drive/client_login_fetcher.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#auth_tokens ⇒ Object
Returns the value of attribute auth_tokens.
Instance Method Summary collapse
-
#initialize(auth_tokens, proxy) ⇒ ClientLoginFetcher
constructor
A new instance of ClientLoginFetcher.
- #request_raw(method, url, data, extra_header, auth) ⇒ Object
Constructor Details
#initialize(auth_tokens, proxy) ⇒ ClientLoginFetcher
Returns a new instance of ClientLoginFetcher.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/google_drive/client_login_fetcher.rb', line 13 def initialize(auth_tokens, proxy) @auth_tokens = auth_tokens 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 Attribute Details
#auth_tokens ⇒ Object
Returns the value of attribute auth_tokens.
25 26 27 |
# File 'lib/google_drive/client_login_fetcher.rb', line 25 def auth_tokens @auth_tokens end |
Instance Method Details
#request_raw(method, url, data, extra_header, auth) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/google_drive/client_login_fetcher.rb', line 27 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 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 |