summary refs log tree commit
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-08-03 13:53:20 -0300
committerJames Tucker <jftucker@gmail.com>2014-08-03 13:53:20 -0300
commit12528d4567d8e6c1c7e9422fee6cd8b43c4389bf (patch)
treebac1a1bd0b61bd61e2e92e45cbfc301722f3983b
parent0f8cd0544cf40ef91a55d7762bcbaf3a360f97f9 (diff)
downloadrack-12528d4567d8e6c1c7e9422fee6cd8b43c4389bf.tar.gz
Rack::ETag correctly marks etags as Weak
Closes #681.
-rw-r--r--lib/rack/etag.rb2
-rw-r--r--test/spec_etag.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/rack/etag.rb b/lib/rack/etag.rb
index 99a1a4c0..fefe671f 100644
--- a/lib/rack/etag.rb
+++ b/lib/rack/etag.rb
@@ -28,7 +28,7 @@ module Rack
         body = Rack::BodyProxy.new(new_body) do
           original_body.close if original_body.respond_to?(:close)
         end
-        headers['ETag'] = %("#{digest}") if digest
+        headers['ETag'] = %(W/"#{digest}") if digest
       end
 
       unless headers['Cache-Control']
diff --git a/test/spec_etag.rb b/test/spec_etag.rb
index b8b8b637..c075d9d0 100644
--- a/test/spec_etag.rb
+++ b/test/spec_etag.rb
@@ -21,13 +21,13 @@ describe Rack::ETag do
   should "set ETag if none is set if status is 200" do
     app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
     response = etag(app).call(request)
-    response[1]['ETag'].should.equal "\"65a8e27d8879283831b664bd8b7f0ad4\""
+    response[1]['ETag'].should.equal "W/\"65a8e27d8879283831b664bd8b7f0ad4\""
   end
 
   should "set ETag if none is set if status is 201" do
     app = lambda { |env| [201, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
     response = etag(app).call(request)
-    response[1]['ETag'].should.equal "\"65a8e27d8879283831b664bd8b7f0ad4\""
+    response[1]['ETag'].should.equal "W/\"65a8e27d8879283831b664bd8b7f0ad4\""
   end
 
   should "set Cache-Control to 'max-age=0, private, must-revalidate' (default) if none is set" do