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.
- data/AUTHORS +26 -0
- data/README.rdoc +7 -3
- data/Rakefile +2 -10
- data/lib/rack/contrib.rb +6 -0
- data/lib/rack/contrib/access.rb +85 -0
- data/lib/rack/contrib/cookies.rb +50 -0
- data/lib/rack/contrib/expectation_cascade.rb +32 -0
- data/lib/rack/contrib/host_meta.rb +47 -0
- data/lib/rack/contrib/jsonp.rb +1 -1
- data/lib/rack/contrib/mailexceptions.rb +1 -1
- data/lib/rack/contrib/profiler.rb +3 -1
- data/lib/rack/contrib/response_headers.rb +24 -0
- data/lib/rack/contrib/runtime.rb +31 -0
- data/lib/rack/contrib/simple_endpoint.rb +81 -0
- data/lib/rack/contrib/static_cache.rb +93 -0
- data/rack-contrib.gemspec +22 -5
- data/test/documents/test +1 -0
- data/test/spec_rack_access.rb +154 -0
- data/test/spec_rack_cookies.rb +56 -0
- data/test/spec_rack_expectation_cascade.rb +72 -0
- data/test/spec_rack_host_meta.rb +50 -0
- data/test/spec_rack_jsonp.rb +5 -5
- data/test/spec_rack_post_body_content_type_parser.rb +1 -1
- data/test/spec_rack_profiler.rb +1 -1
- data/test/spec_rack_response_headers.rb +35 -0
- data/test/spec_rack_runtime.rb +35 -0
- data/test/spec_rack_simple_endpoint.rb +95 -0
- data/test/spec_rack_static_cache.rb +91 -0
- data/test/statics/test +1 -0
- metadata +72 -25
- data/lib/rack/contrib/etag.rb +0 -20
- data/test/spec_rack_etag.rb +0 -23
data/lib/rack/contrib/etag.rb
DELETED
@@ -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
|
data/test/spec_rack_etag.rb
DELETED
@@ -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
|