Skip to content

Commit

Permalink
Fixes cached response creation (having parsed JSON in .content field)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszmajsak committed Jul 25, 2016
1 parent 5a474b5 commit f492066
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _ext/restclient_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ def execute(response)
body = File.read(@cache_file)
headers = {}
headers = JSON.parse(File.read("#{@cache_file}.headers")) if File.exist? "#{@cache_file}.headers"
return RestClient::Response.create(body, RestClient::MockNetHTTPResponse.new(body, 200, headers), @request.args)
cachedResponse = RestClient::Response.create(body.to_json, RestClient::MockNetHTTPResponse.new(body, 200, headers), @request)
class << cachedResponse
attr_accessor :content
end
cachedResponse.content = if 'application/json'.eql? @request.headers[:accept] then JSON.parse(body) else body end;
return cachedResponse
end
end
response
Expand Down

0 comments on commit f492066

Please sign in to comment.