Class: Proxy::Omaha::HttpRequest

Inherits:
Object
  • Object
show all
Includes:
Log, HttpShared
Defined in:
lib/smart_proxy_omaha/http_request.rb

Instance Method Summary collapse

Methods included from HttpShared

#connection_factory

Instance Method Details

#get(url) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/smart_proxy_omaha/http_request.rb', line 8

def get(url)
  http, request = connection_factory(url)

  Timeout::timeout(10) do
    response = http.request(request)

    raise "Error retrieving from #{url}: #{response.class}" unless ["200", "201"].include?(response.code)

    response.body
  end
end

#head(url) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smart_proxy_omaha/http_request.rb', line 20

def head(url)
  http, request = connection_factory(url, :method => :head)

  Timeout::timeout(10) do
    response = http.request(request)

    raise "Error retrieving from #{url}: #{response.class}" unless ["200", "201"].include?(response.code)

    response
  end
end