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 +4 -4
- data/lib/rack/varnish_esi.rb +2 -9
- data/lib/rack/varnish_esi_version.rb +1 -1
- data/test/test_rack_varnish_esi.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11044d6e791e70b715b304592914497b653448cd
|
|
4
|
+
data.tar.gz: 9dac0ea7a4fb74a79e7eb0b8db7dd480df1c8591
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ab5ad8ece2d43f2c3772cec15d8c3acf6cf7af6ce99c2ffbb684958372b3b9f8cfa51aa793d501a5167270f034780dd17f56ec4522d1b156fac758ec1bb810c
|
|
7
|
+
data.tar.gz: 4d3ce23d720b39b86d24e5b0d5f534fd43a612225c8ba095bcbc4c5f1f60075d552b8a815bf016d8b7d9eb47bb8f31a109ca4d78d40dfa19673dba4a5dce3488
|
data/lib/rack/varnish_esi.rb
CHANGED
|
@@ -3,14 +3,7 @@ require 'rack/varnish_esi_processor'
|
|
|
3
3
|
|
|
4
4
|
module Rack
|
|
5
5
|
class VarnishEsi
|
|
6
|
-
VALID_CONTENT_TYPES =
|
|
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
|
|
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
|
|
@@ -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)
|