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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cf579adea45ad1f505bba52d1d58e4c1ba9c025
4
- data.tar.gz: e5d290e8911cab630b61475d9cec57c4b0b49102
3
+ metadata.gz: 16351855fe88c29812d69c2ecb16db0c1a6464bd
4
+ data.tar.gz: b3bbfe68773591d519c7b52434acdfdfe6ab185f
5
5
  SHA512:
6
- metadata.gz: 9f060e04e2e96cdb74e950d1174d4790cca6261f1f6582b179d35f77a237ebce45a2707804c37087e38c318aa5a0917e0bb19678639d7a421b18ba407f91ef33
7
- data.tar.gz: 979dc8102a2beb22980ef4807bc05f167ed5703e3dcdbb4b1d26c8dc0629851e078d12c97dd4f3e8516f033e69b5b7779c2de59bae3b4c14402c56d5fb4f13ac
6
+ metadata.gz: 1d1466a873c657a14ca3f903effb4b8ed11df39f7d9016d5610b1fc430abf51a909dc2f684a8f34ca11e903d1076aa55bfcbf5d94830ef86b9867ea36949c7f7
7
+ data.tar.gz: 04007657836eaffcf46b01aac90f6eb353c58941ca522830d2eb8a817624bb453ba7d1b89b7d022513fd8416121525f260fc6a6f2bd1564690e074bb112b36c8
@@ -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'] =~ /text\/html/
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class VarnishEsi
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -7,4 +7,5 @@ sudo varnishd \
7
7
  -a :6081 \
8
8
  -T localhost:6082 \
9
9
  -f ${CURRENT_DIR}/varnish.vcl \
10
+ -p feature=+esi_disable_xml_check \
10
11
  -s malloc,32m
@@ -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.5
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