Class: Geminabox::HttpClientAdapter

Inherits:
HttpAdapter show all
Defined in:
lib/geminabox/http_adapter/http_client_adapter.rb

Instance Method Summary collapse

Instance Method Details

#get(*args) ⇒ Object



9
10
11
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 9

def get(*args)
  http_client.get(*args)
end

#get_content(*args) ⇒ Object



13
14
15
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 13

def get_content(*args)
  http_client.get_content(*args)
end

#http_clientObject



26
27
28
29
30
31
32
33
34
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 26

def http_client
  @http_client ||= HTTPClient.new(ENV['http_proxy']).tap do |http_client|
    http_client.transparent_gzip_decompression = true
    http_client.keep_alive_timeout = 32 # sec
    http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
    http_client.send_timeout = 0
    http_client.receive_timeout = 0
  end
end

#http_client=(client) ⇒ Object



36
37
38
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 36

def http_client=(client)
  @http_client = client
end

#post(*args) ⇒ Object



17
18
19
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 17

def post(*args)
  http_client.post(*args)
end

#set_auth(url, username = nil, password = nil) ⇒ Object



21
22
23
24
# File 'lib/geminabox/http_adapter/http_client_adapter.rb', line 21

def set_auth(url, username = nil, password = nil)
  http_client.set_auth(url, username, password) if username or password
  http_client.www_auth.basic_auth.challenge(url) # Workaround: https://github.com/nahi/httpclient/issues/63
end