Set Content-Length header for documents on GET

This commit is contained in:
Garret Alfert 2014-01-08 23:27:07 +01:00
parent 75e52f3e9a
commit 6d86fa516a
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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