mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Merge pull request #530 from robdimarco/master
Handle an HTTP Response with a Content-type but no body.
This commit is contained in:
commit
e7f5a5463c
2 changed files with 8 additions and 1 deletions
|
@ -276,7 +276,7 @@ module HTTParty
|
|||
end
|
||||
|
||||
def encode_with_ruby_encoding(body, charset)
|
||||
if Encoding.name_list.include?(charset)
|
||||
if !body.nil? && Encoding.name_list.include?(charset)
|
||||
body.force_encoding(charset)
|
||||
else
|
||||
body
|
||||
|
|
|
@ -485,6 +485,13 @@ RSpec.describe HTTParty::Request do
|
|||
expect(resp.body.encoding).to eq(Encoding.find("UTF-8"))
|
||||
end
|
||||
|
||||
it "should process response with a nil body" do
|
||||
response = stub_response nil
|
||||
response.initialize_http_header("Content-Type" => "text/html;charset=UTF-8")
|
||||
resp = @request.perform
|
||||
expect(resp.body).to be_nil
|
||||
end
|
||||
|
||||
it "should process utf-16 charset with little endian bom correctly" do
|
||||
@request.options[:assume_utf16_is_big_endian] = true
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue