Skip to content

Commit

Permalink
PatronAdapter should use Session#default_response_charset.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Aug 27, 2011
1 parent c573d1a commit eb2e94d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/webmock/http_lib_adapters/patron_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def handle_request_with_webmock(req)
WebMock::HttpLibAdapters::PatronAdapter.
handle_file_name(req, webmock_response)
res = WebMock::HttpLibAdapters::PatronAdapter.
build_patron_response(webmock_response)
build_patron_response(webmock_response, default_response_charset)
WebMock::CallbackRegistry.invoke_callbacks(
{:lib => :patron}, request_signature, webmock_response)
res
Expand Down Expand Up @@ -98,10 +98,10 @@ def self.build_request_signature(req)
request_signature
end

def self.build_patron_response(webmock_response)
def self.build_patron_response(webmock_response, default_response_charset)
raise ::Patron::TimeoutError if webmock_response.should_timeout
webmock_response.raise_error_if_any

header_fields = (webmock_response.headers || []).map { |(k, vs)| Array(vs).map { |v| "#{k}: #{v}" } }.flatten
status_line = "HTTP/1.1 #{webmock_response.status[0]} #{webmock_response.status[1]}"
header_data = ([status_line] + header_fields).join("\r\n")
Expand All @@ -111,7 +111,8 @@ def self.build_patron_response(webmock_response)
webmock_response.status[0],
0,
header_data,
webmock_response.body
webmock_response.body,
default_response_charset
)
end

Expand Down

0 comments on commit eb2e94d

Please sign in to comment.