diff --git a/lib/remote_storage/riak.rb b/lib/remote_storage/riak.rb index 1add990..9b3c2c2 100644 --- a/lib/remote_storage/riak.rb +++ b/lib/remote_storage/riak.rb @@ -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 diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index d5e2183..4865e38 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -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