rails_weak_etags 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd86b1f259beec9ba981654ec19351061e58b577
4
- data.tar.gz: 04074f89d287e4c956281b837a70c03c10fa454e
3
+ metadata.gz: 7e82cbaef485bae04e47132fceeabfbab13ebc68
4
+ data.tar.gz: 9501a45b4dbcb021dc80550df7a23d2d54ed45be
5
5
  SHA512:
6
- metadata.gz: 88a7d8714e1ade3d979372309828b5ff4fe8dafb5b9946c5a30f503602b85811d90296937c080293dfeece56f63d3d241a19662bf577b171f52eb9cbad264eda
7
- data.tar.gz: b50f01ec87cdf2694ef714860486282c4f47a581eb57db29bc301159a051e54cf89515f2c7df9ef06137407ce32c4169bc729e4665250e1a483ddf15df13e5a9
6
+ metadata.gz: 0017e96eccc1803e4f379712b324e5210bc0642e413bf94ded69ebf5c58d058b4ee509a31564551412ae44d2eba1d6c2b8de47da5f31cea0f99f4b22dce7a25b
7
+ data.tar.gz: d27f350ac81859637e1b67e6e8d535f79ca302a3c7b5597fe384d629985a6a431697b879541a000cae5f9ae36836fe2b5f5aca58fb67fd98ab3aa5da702f8835
@@ -6,18 +6,24 @@ module RailsWeakEtags
6
6
  end
7
7
 
8
8
  def call(env)
9
- # make request etags "strong"
10
- etag = env['HTTP_IF_NONE_MATCH']
11
- if etag && etag =~ /^W\//
12
- env['HTTP_IF_NONE_MATCH'] = etag[2..-1]
13
- end
9
+ status, headers, body = nil, nil, nil
14
10
 
15
- status, headers, body = @app.call(env)
11
+ # make request etags "strong" before calling the app. Restore the original
12
+ # header before passing control back. Rack 1.6 added weak e-tag support
13
+ # for digest bodies, so it needs to see the weak etag.
14
+ request_etag = env['HTTP_IF_NONE_MATCH']
15
+ if request_etag && request_etag =~ /^W\//
16
+ env['HTTP_IF_NONE_MATCH'] = request_etag[2..-1]
17
+ status, headers, body = @app.call(env)
18
+ env['HTTP_IF_NONE_MATCH'] = request_etag
19
+ else
20
+ status, headers, body = @app.call(env)
21
+ end
16
22
 
17
- # make response etags "weak"
18
- etag = headers['ETag']
19
- if etag && etag !~ /^W\//
20
- headers['ETag'] = "W/#{etag}"
23
+ # make all response etags "weak"
24
+ response_etag = headers['ETag']
25
+ if response_etag && response_etag !~ /^W\//
26
+ headers['ETag'] = "W/#{response_etag}"
21
27
  end
22
28
 
23
29
  [status, headers, body]
@@ -1,7 +1,7 @@
1
1
  module RailsWeakEtags
2
2
  class Railtie < ::Rails::Railtie
3
3
  initializer "rails_weak_etags.configure_rails_initialization" do |app|
4
- app.middleware.insert_before(Rack::ConditionalGet, RailsWeakEtags::Middleware)
4
+ app.middleware.insert_before(Rack::ETag, RailsWeakEtags::Middleware)
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module RailsWeakEtags
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_weak_etags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Naegle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -46,12 +46,14 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - MIT-LICENSE
50
+ - Rakefile
51
+ - lib/rails_weak_etags.rb
49
52
  - lib/rails_weak_etags/middleware.rb
50
53
  - lib/rails_weak_etags/railtie.rb
51
54
  - lib/rails_weak_etags/version.rb
52
- - lib/rails_weak_etags.rb
53
- - MIT-LICENSE
54
- - Rakefile
55
+ - test/dummy/README.rdoc
56
+ - test/dummy/Rakefile
55
57
  - test/dummy/app/assets/javascripts/application.js
56
58
  - test/dummy/app/assets/stylesheets/application.css
57
59
  - test/dummy/app/controllers/application_controller.rb
@@ -60,6 +62,7 @@ files:
60
62
  - test/dummy/bin/bundle
61
63
  - test/dummy/bin/rails
62
64
  - test/dummy/bin/rake
65
+ - test/dummy/config.ru
63
66
  - test/dummy/config/application.rb
64
67
  - test/dummy/config/boot.rb
65
68
  - test/dummy/config/database.yml
@@ -76,14 +79,11 @@ files:
76
79
  - test/dummy/config/initializers/wrap_parameters.rb
77
80
  - test/dummy/config/locales/en.yml
78
81
  - test/dummy/config/routes.rb
79
- - test/dummy/config.ru
80
82
  - test/dummy/log/development.log
81
83
  - test/dummy/public/404.html
82
84
  - test/dummy/public/422.html
83
85
  - test/dummy/public/500.html
84
86
  - test/dummy/public/favicon.ico
85
- - test/dummy/Rakefile
86
- - test/dummy/README.rdoc
87
87
  - test/integration/navigation_test.rb
88
88
  - test/rails_weak_etags_test.rb
89
89
  - test/test_helper.rb
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.0.3
109
+ rubygems_version: 2.4.5
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Converts strong e-tags to weak.
@@ -146,4 +146,3 @@ test_files:
146
146
  - test/integration/navigation_test.rb
147
147
  - test/rails_weak_etags_test.rb
148
148
  - test/test_helper.rb
149
- has_rdoc: