rack-varnish-esi 0.0.5 → 0.0.6
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 +10 -1
- data/lib/rack/varnish_esi_version.rb +1 -1
- data/test/fixtures/run_varnish.sh +1 -0
- data/test/fixtures/varnish_output.html +4 -0
- data/test/static_server/public/index.html +4 -0
- data/test/static_server/public/test.css +1 -0
- data/test/static_server/public/test.js +1 -0
- data/test/static_server/public/test.json +1 -0
- data/test/static_server/public/test.xml +1 -0
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16351855fe88c29812d69c2ecb16db0c1a6464bd
|
|
4
|
+
data.tar.gz: b3bbfe68773591d519c7b52434acdfdfe6ab185f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d1466a873c657a14ca3f903effb4b8ed11df39f7d9016d5610b1fc430abf51a909dc2f684a8f34ca11e903d1076aa55bfcbf5d94830ef86b9867ea36949c7f7
|
|
7
|
+
data.tar.gz: 04007657836eaffcf46b01aac90f6eb353c58941ca522830d2eb8a817624bb453ba7d1b89b7d022513fd8416121525f260fc6a6f2bd1564690e074bb112b36c8
|
data/lib/rack/varnish_esi.rb
CHANGED
|
@@ -3,6 +3,15 @@ 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
|
|
14
|
+
|
|
6
15
|
def initialize(app, options={})
|
|
7
16
|
@app = app
|
|
8
17
|
@processor = Rack::VarnishEsiProcessor.new(options[:locations] || {})
|
|
@@ -11,7 +20,7 @@ module Rack
|
|
|
11
20
|
def call(env)
|
|
12
21
|
status, headers, body = @app.call(env)
|
|
13
22
|
|
|
14
|
-
if headers['Content-Type']
|
|
23
|
+
if VALID_CONTENT_TYPES.include?(headers['Content-Type'])
|
|
15
24
|
body.close if body.respond_to?(:close)
|
|
16
25
|
body = @processor.process(body)
|
|
17
26
|
headers['Content-Length'] = (body.reduce(0) {|sum, part| sum + part.bytesize}).to_s
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
HTML notation: Thomas<br>
|
|
9
9
|
Recursive: <span>Thomas Marek</span><br>
|
|
10
10
|
Unicode: €10<br>
|
|
11
|
+
CSS: body { font-family: 'Thomas' }<br>
|
|
12
|
+
Javascript: var last_name = "Thomas";<br>
|
|
13
|
+
JSON: {"name": "Thomas Marek"}<br>
|
|
14
|
+
XML: <name>Thomas Marek</name><br>
|
|
11
15
|
Alternative option: File not found: /unknown
|
|
12
16
|
<br>
|
|
13
17
|
Different host: Thomas<br>
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
HTML notation: <esi:include src="/first_name.txt"><br>
|
|
9
9
|
Recursive: <esi:include src="/subdir/full_name.html"/><br>
|
|
10
10
|
Unicode: <esi:include src="/unicode.txt"/><br>
|
|
11
|
+
CSS: <esi:include src="test.css"/><br>
|
|
12
|
+
Javascript: <esi:include src="test.js"/><br>
|
|
13
|
+
JSON: <esi:include src="test.json"/><br>
|
|
14
|
+
XML: <esi:include src="test.xml"/><br>
|
|
11
15
|
Alternative option: <esi:include src="/unknown" alt="/first_name.txt"/><br>
|
|
12
16
|
Different host: <esi:include src="http://www.google.com/first_name.txt"/><br>
|
|
13
17
|
No leading slash: <esi:include src="first_name.txt"/><br>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
body { font-family: '<esi:include src="/first_name.txt" />' }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var last_name = "<esi:include src="/first_name.txt" />";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "<esi:include src="/first_name.txt" /> Marek"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<name><esi:include src="/first_name.txt" /> Marek</name>
|
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.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Marek
|
|
@@ -109,6 +109,10 @@ files:
|
|
|
109
109
|
- test/static_server/public/index.html
|
|
110
110
|
- test/static_server/public/last_name.txt
|
|
111
111
|
- test/static_server/public/subdir/full_name.html
|
|
112
|
+
- test/static_server/public/test.css
|
|
113
|
+
- test/static_server/public/test.js
|
|
114
|
+
- test/static_server/public/test.json
|
|
115
|
+
- test/static_server/public/test.xml
|
|
112
116
|
- test/static_server/public/unicode.txt
|
|
113
117
|
- test/test_rack_varnish_esi.rb
|
|
114
118
|
- test/test_varnish_esi_processor.rb
|
|
@@ -147,6 +151,10 @@ test_files:
|
|
|
147
151
|
- test/static_server/public/index.html
|
|
148
152
|
- test/static_server/public/last_name.txt
|
|
149
153
|
- test/static_server/public/subdir/full_name.html
|
|
154
|
+
- test/static_server/public/test.css
|
|
155
|
+
- test/static_server/public/test.js
|
|
156
|
+
- test/static_server/public/test.json
|
|
157
|
+
- test/static_server/public/test.xml
|
|
150
158
|
- test/static_server/public/unicode.txt
|
|
151
159
|
- test/test_rack_varnish_esi.rb
|
|
152
160
|
- test/test_varnish_esi_processor.rb
|