Class: Bing::Request

Inherits:
Object show all
Defined in:
lib/bing/request.rb

Overview

Responsible for making requests to Bing. Uses persistent HTTP connections.

Constant Summary collapse

HTTP =
Net::HTTP::Persistent.new
USER_AGENT =
"Bing Client Version: #{Bing::VERSION}"

Class Method Summary collapse

Class Method Details

.get(uri) ⇒ Object

Perform a get request and ensure that the response.code == 20d, otherwise raise a BadGateway.



13
14
15
16
17
18
19
20
21
22
# File 'lib/bing/request.rb', line 13

def self.get uri
  response = HTTP.request uri

  puts uri if ENV['DEBUG']

  raise Bing::BadGateway.bad_response(response.code, uri) unless
    response.code =~ /20\d/

  response
end