rack-contrib 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-contrib might be problematic. Click here for more details.

@@ -1,20 +0,0 @@
1
- require 'digest/md5'
2
-
3
- module Rack
4
- # Automatically sets the ETag header on all String bodies
5
- class ETag
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- status, headers, body = @app.call(env)
12
-
13
- if !headers.has_key?('ETag') && body.is_a?(String)
14
- headers['ETag'] = %("#{Digest::MD5.hexdigest(body)}")
15
- end
16
-
17
- [status, headers, body]
18
- end
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- require 'test/spec'
2
- require 'rack/mock'
3
- require 'rack/contrib/etag'
4
-
5
- context "Rack::ETag" do
6
- specify "sets ETag if none is set" do
7
- app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] }
8
- response = Rack::ETag.new(app).call({})
9
- response[1]['ETag'].should.equal "\"65a8e27d8879283831b664bd8b7f0ad4\""
10
- end
11
-
12
- specify "does not change ETag if it is already set" do
13
- app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'ETag' => '"abc"'}, "Hello, World!"] }
14
- response = Rack::ETag.new(app).call({})
15
- response[1]['ETag'].should.equal "\"abc\""
16
- end
17
-
18
- specify "does not set ETag if steaming body" do
19
- app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello", "World"]] }
20
- response = Rack::ETag.new(app).call({})
21
- response[1]['ETag'].should.equal nil
22
- end
23
- end