Fix a bug when a document has an empty body

Add check on content length for an empty file
This commit is contained in:
Greg Karékinian 2015-03-03 21:56:19 +01:00
parent 247559e563
commit a15635ce38
2 changed files with 5 additions and 1 deletions

View File

@ -68,7 +68,10 @@ module RemoteStorage
when "application/json"
return object.data.to_json
else
return serializer_for(object.content_type) ? object.data : object.raw_data
data = serializer_for(object.content_type) ? object.data : object.raw_data
# Never return nil, always turn data into a string
return data.nil? ? '' : data
end
rescue ::Riak::HTTPFailedRequest
server.halt 404

View File

@ -76,6 +76,7 @@ describe "App with Riak backend" do
it "returns an empty body" do
last_response.status.must_equal 200
last_response.body.must_equal ""
last_response.headers["Content-Length"].must_equal '0'
end
end
end