rack-easy_brotli 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90c6a421a62be6d4257439c1f4c3b551bbd130347746aa169a32057cb0acb77c
4
- data.tar.gz: 9d07efecfaab4ea4a1e451888d21cc711a0885dff2b69ef2ffc4ef63b6f26739
3
+ metadata.gz: 4ba33d8d9b2e3867296540cb06b46ed5296fa6caa7a43156f392b3dd54265203
4
+ data.tar.gz: 2a420d3f16702bb92f9abce28740072c475deb6b17059414e529a055c1e2d664
5
5
  SHA512:
6
- metadata.gz: adb6aebce3c4c444b6320104b5b1212cf437ae8c32cecd88a3cb75f409702f10c3d295cdb18a16c6382f71b713cc5e70a959320ea3fced996697299822b07e6e
7
- data.tar.gz: a924c24565f9ce5dea893277147023622002172c10015abaf61ca6a945117ec573ac5a6d51d8dba17b21bb609e7ea0b95c783757657bb1b8a60f58334a4e6a18
6
+ metadata.gz: f971c22b9381c9a3abfcb6bf8ab8f992652d8749b259cba85aa9dbaaeada46e8a56debf730b8699ff9bece059a83705a07968d3849cdd9d02ffeaab5c7883d8e
7
+ data.tar.gz: 20958c1f3fc658f81f0e231c74d35db3da0be5a54d002880fff1157916538fbd01cb8af0a035625837648acc07e393d77b13fb5e8fc5178a08d2757821acc4a4
data/lib/rack/brotli.rb CHANGED
@@ -1,4 +1,3 @@
1
- require_relative 'brotli/instrument'
2
1
  require_relative 'brotli/deflater'
3
2
  require_relative 'brotli/version'
4
3
  require_relative 'brotli/railtie' if defined?(::Rails)
@@ -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
- instrument(request) do
58
- # Set the Vary HTTP header.
59
- vary = headers["Vary"].to_s.split(",").map(&:strip)
60
- unless vary.include?("*") || vary.include?("Accept-Encoding")
61
- headers["Vary"] = vary.push("Accept-Encoding").join(",")
62
- end
63
-
64
- case encoding
65
- when "br"
66
- headers['Content-Encoding'] = "br"
67
- headers.delete('Content-Length')
68
- [status, headers, BrotliStream.new(body, @deflater_options)]
69
- when nil
70
- message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found."
71
- bp = Rack::BodyProxy.new([message]) { body.close if body.respond_to?(:close) }
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
- header
98
+ headers
113
99
  else
114
100
  Rack::Utils::HeaderHash.new(headers) # rack < 2.2
115
101
  end
@@ -4,7 +4,7 @@ module Rack
4
4
  module Brotli
5
5
  class Version
6
6
  def self.to_s
7
- '1.2.0'
7
+ '1.2.1'
8
8
  end
9
9
  end
10
10
  end
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.0
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
@@ -1,11 +0,0 @@
1
- # dummy implementation for non-rails environments
2
-
3
- module Rack
4
- module Brotli
5
- class Instrument
6
- def self.instrument(name, **args, &block)
7
- yield
8
- end
9
- end
10
- end
11
- end