diff --git a/lib/remote_storage/riak.rb b/lib/remote_storage/riak.rb index 14d485c..e5c129d 100644 --- a/lib/remote_storage/riak.rb +++ b/lib/remote_storage/riak.rb @@ -43,6 +43,7 @@ module RemoteStorage server.headers["Content-Type"] = object.content_type server.headers["Last-Modified"] = last_modified_date_for(object) server.headers["ETag"] = object.etag + server.headers["Content-Length"] = object_size(object) server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == object.etag diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index ac23f14..406ffc1 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -38,6 +38,11 @@ describe "App with Riak backend" do last_response.headers["ETag"].wont_be_nil end + it "has a Content-Length header set" do + last_response.status.must_equal 200 + last_response.headers["Content-Length"].must_equal "14" + end + it "has caching headers set" do last_response.status.must_equal 200 last_response.headers["Expires"].must_equal "0" @@ -385,6 +390,12 @@ describe "App with Riak backend" do last_response.headers["ETag"].must_equal etag end + it "responds with a Content-Length header" do + get "/jimmy/documents/jaypeg" + + last_response.headers["Content-Length"].must_equal "16044" + end + it "changes the ETag when updating the file" do old_etag = last_response.headers["ETag"] put "/jimmy/documents/jaypeg", @image