mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
parent
8ba78988ad
commit
1bb58653a8
2 changed files with 13 additions and 1 deletions
|
@ -56,7 +56,9 @@ module RestClient
|
|||
begin
|
||||
encoding = Encoding.find(charset) if charset
|
||||
rescue ArgumentError
|
||||
RestClient.log << "No such encoding: #{charset.inspect}"
|
||||
if RestClient.log
|
||||
RestClient.log << "No such encoding: #{charset.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
return unless encoding
|
||||
|
|
|
@ -98,6 +98,16 @@ describe RestClient do
|
|||
response.encoding.should eq Encoding.default_external
|
||||
end
|
||||
|
||||
it 'handles invalid encoding' do
|
||||
stub_request(:get, 'www.example.com').to_return(
|
||||
body: 'abc', status: 200, headers: {
|
||||
'Content-Type' => 'text; charset=plain'
|
||||
})
|
||||
|
||||
response = RestClient.get 'www.example.com'
|
||||
response.encoding.should eq Encoding.default_external
|
||||
end
|
||||
|
||||
it 'leaves images as binary' do
|
||||
gif = Base64.strict_decode64('R0lGODlhAQABAAAAADs=')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue