rack-wwwhisper 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,10 +19,14 @@ class NoPublicCache
19
19
  status, headers, body = @app.call(env)
20
20
  if cache_control = headers['Cache-Control']
21
21
  # If caching is enabled, make sure it is private.
22
- if (not cache_control.gsub!(/public/, 'private') and
22
+ cache_control = cache_control.gsub(/public/, 'private')
23
+ if (not cache_control.include? 'private' and
23
24
  cache_control.index(/max-age\s*=\s*0*[1-9]/))
24
- cache_control.insert(0, 'private, ')
25
+ # max-age > 0 without 'public' or 'private' directive is
26
+ # treated as 'public', so 'private' needs to be prepended.
27
+ cache_control.insert(0, 'private, ')
25
28
  end
29
+ headers['Cache-Control'] = cache_control
26
30
  end
27
31
  [status, headers, body]
28
32
  end
@@ -29,7 +29,8 @@ class MockBackend
29
29
  end
30
30
 
31
31
  def add_response_header(key, value)
32
- @response[1][key] = value
32
+ # Frozen strings as header values must be handled correctly.
33
+ @response[1][key] = value.freeze
33
34
  end
34
35
 
35
36
  end
@@ -354,8 +355,8 @@ class TestWWWhisper < Test::Unit::TestCase
354
355
  path = '/foo/bar'
355
356
  stub_request(:get, full_url(@wwwhisper.auth_query(path))).
356
357
  to_return(granted())
357
- @backend.add_response_header('Cache-Control', 'public, max-age=60')
358
358
 
359
+ @backend.add_response_header('Cache-Control', 'public, max-age=60')
359
360
  get path
360
361
  assert last_response.ok?
361
362
  assert_equal 'private, max-age=60', last_response['Cache-Control']
@@ -364,6 +365,12 @@ class TestWWWhisper < Test::Unit::TestCase
364
365
  get path
365
366
  assert last_response.ok?
366
367
  assert_equal 'private, max-age=60', last_response['Cache-Control']
368
+
369
+ @backend.add_response_header('Cache-Control', 'private, max-age=60')
370
+ get path
371
+ assert last_response.ok?
372
+ assert_equal 'private, max-age=60', last_response['Cache-Control']
373
+
367
374
  end
368
375
 
369
376
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-wwwhisper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -4405127786806447004
134
+ hash: 411330195400284462
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: -4405127786806447004
143
+ hash: 411330195400284462
144
144
  requirements: []
145
145
  rubyforge_project:
146
146
  rubygems_version: 1.8.24