Permalink
Browse files

Expose typhoeus Request opts

  • Loading branch information...
1 parent 22daf09 commit 66c071cf8e125b763730100c5112d010719f8710 @chadrem committed Jul 28, 2012
Showing with 5 additions and 3 deletions.
  1. +3 −2 lib/market_bot/android/app.rb
  2. +2 −1 lib/market_bot/android/leaderboard.rb
@@ -142,6 +142,7 @@ def self.parse(html)
def initialize(app_id, options={})
@app_id = app_id
@hydra = options[:hydra] || MarketBot.hydra
+ @request_opts = options[:request_opts] || {}
@callback = nil
@error = nil
end
@@ -151,7 +152,7 @@ def market_url
end
def update
- resp = Typhoeus::Request.get(market_url)
+ resp = Typhoeus::Request.get(market_url, @request_opts)
result = App.parse(resp.body)
update_callback(result)
@@ -162,7 +163,7 @@ def enqueue_update(&block)
@callback = block
@error = nil
- request = Typhoeus::Request.new(market_url)
+ request = Typhoeus::Request.new(market_url, @request_opts)
request.on_complete do |response|
# HACK: Typhoeus <= 0.4.2 returns a response, 0.5.0pre returns the request.
@@ -67,6 +67,7 @@ def initialize(identifier, category=nil, options={})
@identifier = identifier
@category = category
@hydra = options[:hydra] || MarketBot.hydra
+ @request_opts = options[:request_opts] || {}
@parsed_results = []
end
@@ -129,7 +130,7 @@ def results
private
def process_page(url, page_num)
- request = Typhoeus::Request.new(url)
+ request = Typhoeus::Request.new(url, @request_opts)
request.on_complete do |response|
# HACK: Typhoeus <= 0.4.2 returns a response, 0.5.0pre returns the request.
response = response.response if response.is_a?(Typhoeus::Request)

0 comments on commit 66c071c

Please sign in to comment.