lib/smoke/request.rb in benschwarz-smoke-0.4.1 vs lib/smoke/request.rb in benschwarz-smoke-0.4.2

- old
+ new

@@ -8,27 +8,30 @@ Smoke.log.error "Smoke Request: Failed to get from #{@uri} (#{msg})" end end SUPPORTED_TYPES = %w(json xml javascript) + @@request_options = { + :user_agent => Smoke.config[:user_agent], + :accept_encoding => "gzip" + } + attr_reader :uri, :content_type, :body, :type def initialize(uri, options = {}) @uri, @options = uri, options dispatch end private - def dispatch - opts = { - :user_agent => Smoke.config[:user_agent], - :accept_encoding => "gzip" - } - Thread.new { - request = RestClient.get(@uri, opts) - @content_type = request.headers[:content_type] - @body = request - }.join + def dispatch + Smoke::Cache.fetch @uri do + Thread.new { + request = RestClient.get(@uri, @@request_options) + @content_type = request.headers[:content_type] + @body = request + }.join + end present! unless @options[:raw_response] rescue RestClient::Exception => e Failure.new(@uri, e) \ No newline at end of file