rack-varnish-esi 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16351855fe88c29812d69c2ecb16db0c1a6464bd
4
- data.tar.gz: b3bbfe68773591d519c7b52434acdfdfe6ab185f
3
+ metadata.gz: 11044d6e791e70b715b304592914497b653448cd
4
+ data.tar.gz: 9dac0ea7a4fb74a79e7eb0b8db7dd480df1c8591
5
5
  SHA512:
6
- metadata.gz: 1d1466a873c657a14ca3f903effb4b8ed11df39f7d9016d5610b1fc430abf51a909dc2f684a8f34ca11e903d1076aa55bfcbf5d94830ef86b9867ea36949c7f7
7
- data.tar.gz: 04007657836eaffcf46b01aac90f6eb353c58941ca522830d2eb8a817624bb453ba7d1b89b7d022513fd8416121525f260fc6a6f2bd1564690e074bb112b36c8
6
+ metadata.gz: 8ab5ad8ece2d43f2c3772cec15d8c3acf6cf7af6ce99c2ffbb684958372b3b9f8cfa51aa793d501a5167270f034780dd17f56ec4522d1b156fac758ec1bb810c
7
+ data.tar.gz: 4d3ce23d720b39b86d24e5b0d5f534fd43a612225c8ba095bcbc4c5f1f60075d552b8a815bf016d8b7d9eb47bb8f31a109ca4d78d40dfa19673dba4a5dce3488
@@ -3,14 +3,7 @@ require 'rack/varnish_esi_processor'
3
3
 
4
4
  module Rack
5
5
  class VarnishEsi
6
- VALID_CONTENT_TYPES = %w(
7
- application/javascript
8
- application/json
9
- application/xml
10
- text/css
11
- text/html
12
- text/plain
13
- ).freeze
6
+ VALID_CONTENT_TYPES = /^(application\/javascript|application\/json|application\/xml|text\/css|text\/html|text\/plain)/
14
7
 
15
8
  def initialize(app, options={})
16
9
  @app = app
@@ -20,7 +13,7 @@ module Rack
20
13
  def call(env)
21
14
  status, headers, body = @app.call(env)
22
15
 
23
- if VALID_CONTENT_TYPES.include?(headers['Content-Type'])
16
+ if headers['Content-Type'] =~ VALID_CONTENT_TYPES
24
17
  body.close if body.respond_to?(:close)
25
18
  body = @processor.process(body)
26
19
  headers['Content-Length'] = (body.reduce(0) {|sum, part| sum + part.bytesize}).to_s
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class VarnishEsi
3
- VERSION = "0.0.6"
3
+ VERSION = '0.0.7'.freeze
4
4
  end
5
5
  end
@@ -23,6 +23,18 @@ class TestRackVarnishEsi < Minitest::Test
23
23
  end
24
24
  end
25
25
 
26
+ def test_that_it_accepts_content_type_parameters
27
+ body_mock = Minitest::Mock.new
28
+ app_mock = Minitest::Mock.new
29
+ app_mock.expect(:call, [200, {"Content-Type" => "text/html; charset=utf-8"}, body_mock], ["test_env" => true])
30
+ body_mock.expect(:close, nil)
31
+ body_mock.expect(:each, nil)
32
+ middleware = Rack::VarnishEsi.new(app_mock)
33
+ middleware.call({"test_env" => true})
34
+ app_mock.verify
35
+ body_mock.verify
36
+ end
37
+
26
38
  protected
27
39
 
28
40
  def start_http_server_with_varnish_esi_middleware(varnish_esi_options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-varnish-esi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Marek