Set Content-Length header for documents on GET
This commit is contained in:
parent
75e52f3e9a
commit
6d86fa516a
@ -43,6 +43,7 @@ module RemoteStorage
|
|||||||
server.headers["Content-Type"] = object.content_type
|
server.headers["Content-Type"] = object.content_type
|
||||||
server.headers["Last-Modified"] = last_modified_date_for(object)
|
server.headers["Last-Modified"] = last_modified_date_for(object)
|
||||||
server.headers["ETag"] = object.etag
|
server.headers["ETag"] = object.etag
|
||||||
|
server.headers["Content-Length"] = object_size(object)
|
||||||
|
|
||||||
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == object.etag
|
server.halt 304 if server.env["HTTP_IF_NONE_MATCH"] == object.etag
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ describe "App with Riak backend" do
|
|||||||
last_response.headers["ETag"].wont_be_nil
|
last_response.headers["ETag"].wont_be_nil
|
||||||
end
|
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
|
it "has caching headers set" do
|
||||||
last_response.status.must_equal 200
|
last_response.status.must_equal 200
|
||||||
last_response.headers["Expires"].must_equal "0"
|
last_response.headers["Expires"].must_equal "0"
|
||||||
@ -385,6 +390,12 @@ describe "App with Riak backend" do
|
|||||||
last_response.headers["ETag"].must_equal etag
|
last_response.headers["ETag"].must_equal etag
|
||||||
end
|
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
|
it "changes the ETag when updating the file" do
|
||||||
old_etag = last_response.headers["ETag"]
|
old_etag = last_response.headers["ETag"]
|
||||||
put "/jimmy/documents/jaypeg", @image
|
put "/jimmy/documents/jaypeg", @image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user