Skip to content

Commit

Permalink
Don't try to deserialise responses with content length = 0
Browse files Browse the repository at this point in the history
For compatibility with Cowboy 2.7.0 and future versions of RabbitMQ.

Supersedes and closes #36.
  • Loading branch information
michaelklishin committed Nov 27, 2018
1 parent 8c7158b commit 93c3030
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/rabbitmq/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,17 @@ def uri_encode(s)
end

def decode_resource(response)
Hashie::Mash.new(response.body)
case response.headers["content-length"]
when nil then Hashie::Mash.new
when 0 then Hashie::Mash.new
when "0" then Hashie::Mash.new
else
if response.body.empty?
Hashie::Mash.new
else
Hashie::Mash.new(response.body)
end
end
end

def decode_resource_collection(response)
Expand Down

0 comments on commit 93c3030

Please sign in to comment.