rack-easy_brotli 1.2.0 → 1.2.1
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/brotli.rb +0 -1
- data/lib/rack/brotli/deflater.rb +16 -30
- data/lib/rack/brotli/version.rb +1 -1
- metadata +1 -2
- data/lib/rack/brotli/instrument.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ba33d8d9b2e3867296540cb06b46ed5296fa6caa7a43156f392b3dd54265203
|
4
|
+
data.tar.gz: 2a420d3f16702bb92f9abce28740072c475deb6b17059414e529a055c1e2d664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f971c22b9381c9a3abfcb6bf8ab8f992652d8749b259cba85aa9dbaaeada46e8a56debf730b8699ff9bece059a83705a07968d3849cdd9d02ffeaab5c7883d8e
|
7
|
+
data.tar.gz: 20958c1f3fc658f81f0e231c74d35db3da0be5a54d002880fff1157916538fbd01cb8af0a035625837648acc07e393d77b13fb5e8fc5178a08d2757821acc4a4
|
data/lib/rack/brotli.rb
CHANGED
data/lib/rack/brotli/deflater.rb
CHANGED
@@ -29,11 +29,6 @@ module Rack::Brotli
|
|
29
29
|
|
30
30
|
@condition = options[:if]
|
31
31
|
@compressible_types = options[:include]
|
32
|
-
if defined?(ActiveSupport::Notifications)
|
33
|
-
@notifier = ActiveSupport::Notifications
|
34
|
-
else
|
35
|
-
@notifier = Rack::Brotli::Instrument
|
36
|
-
end
|
37
32
|
@deflater_options = { quality: 5 }
|
38
33
|
@deflater_options.merge!(options[:deflater]) if options[:deflater]
|
39
34
|
@deflater_options
|
@@ -54,23 +49,21 @@ module Rack::Brotli
|
|
54
49
|
|
55
50
|
return [status, headers, body] unless encoding
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
[406, {'Content-Type' => "text/plain", 'Content-Length' => message.length.to_s}, bp]
|
73
|
-
end
|
52
|
+
# Set the Vary HTTP header.
|
53
|
+
vary = headers["Vary"].to_s.split(",").map(&:strip)
|
54
|
+
unless vary.include?("*") || vary.include?("Accept-Encoding")
|
55
|
+
headers["Vary"] = vary.push("Accept-Encoding").join(",")
|
56
|
+
end
|
57
|
+
|
58
|
+
case encoding
|
59
|
+
when "br"
|
60
|
+
headers['Content-Encoding'] = "br"
|
61
|
+
headers.delete('Content-Length')
|
62
|
+
[status, headers, BrotliStream.new(body, @deflater_options)]
|
63
|
+
when nil
|
64
|
+
message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found."
|
65
|
+
bp = Rack::BodyProxy.new([message]) { body.close if body.respond_to?(:close) }
|
66
|
+
[406, {'Content-Type' => "text/plain", 'Content-Length' => message.length.to_s}, bp]
|
74
67
|
end
|
75
68
|
end
|
76
69
|
|
@@ -100,16 +93,9 @@ module Rack::Brotli
|
|
100
93
|
|
101
94
|
private
|
102
95
|
|
103
|
-
# instrument for performance metrics
|
104
|
-
def instrument(request, &block)
|
105
|
-
@notifier.instrument("rack.brotli", request: request) do
|
106
|
-
yield
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
96
|
def header_hash(headers)
|
111
97
|
if headers.is_a?(Rack::Utils::HeaderHash)
|
112
|
-
|
98
|
+
headers
|
113
99
|
else
|
114
100
|
Rack::Utils::HeaderHash.new(headers) # rack < 2.2
|
115
101
|
end
|
data/lib/rack/brotli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-easy_brotli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Costa
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- README.md
|
107
107
|
- lib/rack/brotli.rb
|
108
108
|
- lib/rack/brotli/deflater.rb
|
109
|
-
- lib/rack/brotli/instrument.rb
|
110
109
|
- lib/rack/brotli/railtie.rb
|
111
110
|
- lib/rack/brotli/version.rb
|
112
111
|
- lib/rack/easy_brotli.rb
|