lib/blekko-search/blekko.rb in blekko-search-0.0.6 vs lib/blekko-search/blekko.rb in blekko-search-0.0.7

- old
+ new

@@ -36,13 +36,21 @@ def slashtag(name, args={}) Blekko::Slashtag.new(self, name, args) end - def request(url) + def http_class + BlekkoSearch.http_class || Net::HTTP + end + + def request(path) sleep(seconds_until_next_request) self.last_request_at = Time.now - open(url, headers) + http_class.start("blekko.com", 80) do |http| + request = Net::HTTP::Get.new path + headers.each { |key, value| request[key] = value } + http.request(request).body + end end def login_uri URI("#{SECURE_PROTOCOL}#{HOST}/login?u=#{CGI.escape(username)}&p=#{CGI.escape(password)}&auth=#{api_key}") end