faraday-gzip 3.0.1-java → 3.0.3-java

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
  SHA256:
3
- metadata.gz: 1df92d36530a0608d50afebd17a70f7fa3ffa952657ba4dd3064c9abfd816e69
4
- data.tar.gz: f280092b520241d785c612beca9241d058a1e5a8a4828c3d57eead4e01f89e30
3
+ metadata.gz: 17666fe2e2a30509ec9173da0697d00e80a369c4648f73677265d2a7dcf0b1c4
4
+ data.tar.gz: addcebd6cdaf899a4cb6de9981e9a6636f39356daf7efc61a867cb76205b752e
5
5
  SHA512:
6
- metadata.gz: 38dbf695901800328fda29a6d7a921711e7c54cee6e16e443b9b7d71e1acf9fedf833b7df7c2e9893d10a3ea18f4590e201c1eec67c97d74008c111ff5dcbe81
7
- data.tar.gz: 157e675d8b6a473b3f84d7504a91a863f93b75be2559e4fe97cd7b7ab43fc69756119a8988412bace723a0e58a1631dc10b06590e1b729a34e626a5d92fc71e5
6
+ metadata.gz: ab647bcc8bf2a617a53de3f71b1c3dc75a33967409da4ce79808c281fa30b43024812eb45c89a539c43f886c052603811876554eca04495cfa1f19616224a120
7
+ data.tar.gz: d1fb7c1b5883cbc5921534d72efb2762bdb24c253aa9c585893661ead116afec0e6d976ff46bdd1f96f0eb081bf28fa04bc3562fbab3c0c3769c200cee0ff485
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 3.0.1 (01-Nov-2024)
3
+ ## 3.0.3 (25-Feb-2025)
4
4
 
5
- * Minor fix in gemspec
5
+ * Minor code fixes, make some methods more solid
6
+
7
+ ## 3.0.1 / 3.0.2 (01-Nov-2024)
8
+
9
+ * Minor fixes in gemspec
6
10
 
7
11
  ## 3.0.0 (29-Oct-2024)
8
12
 
@@ -67,7 +67,11 @@ module Faraday
67
67
  def uncompress_gzip(body)
68
68
  io = StringIO.new(body)
69
69
  gzip_reader = Zlib::GzipReader.new(io, encoding: 'ASCII-8BIT')
70
- gzip_reader.read
70
+ begin
71
+ gzip_reader.read
72
+ ensure
73
+ gzip_reader.close
74
+ end
71
75
  end
72
76
 
73
77
  # Process deflate
@@ -103,7 +107,7 @@ module Faraday
103
107
 
104
108
  # Method providing the processors
105
109
  def processors
106
- {
110
+ @processors ||= {
107
111
  'gzip' => ->(body) { uncompress_gzip(body) },
108
112
  'deflate' => ->(body) { inflate(body) },
109
113
  'br' => ->(body) { brotli_inflate(body) }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module Gzip
5
- VERSION = '3.0.1'
5
+ VERSION = '3.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-gzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.3
5
5
  platform: java
6
6
  authors:
7
7
  - Ilya Krukowski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-01 00:00:00.000000000 Z
10
+ date: 2025-02-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
13
+ name: faraday
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
@@ -19,7 +19,6 @@ dependencies:
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3'
22
- name: faraday
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,12 +30,12 @@ dependencies:
31
30
  - !ruby/object:Gem::Version
32
31
  version: '3'
33
32
  - !ruby/object:Gem::Dependency
33
+ name: bundler
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
38
  version: '2.0'
39
- name: bundler
40
39
  type: :development
41
40
  prerelease: false
42
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,12 +44,12 @@ dependencies:
45
44
  - !ruby/object:Gem::Version
46
45
  version: '2.0'
47
46
  - !ruby/object:Gem::Dependency
47
+ name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '13.0'
53
- name: rake
54
53
  type: :development
55
54
  prerelease: false
56
55
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,12 +58,12 @@ dependencies:
59
58
  - !ruby/object:Gem::Version
60
59
  version: '13.0'
61
60
  - !ruby/object:Gem::Dependency
61
+ name: rspec
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '3.0'
67
- name: rspec
68
67
  type: :development
69
68
  prerelease: false
70
69
  version_requirements: !ruby/object:Gem::Requirement
@@ -73,12 +72,12 @@ dependencies:
73
72
  - !ruby/object:Gem::Version
74
73
  version: '3.0'
75
74
  - !ruby/object:Gem::Dependency
75
+ name: simplecov
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0.22'
81
- name: simplecov
82
81
  type: :development
83
82
  prerelease: false
84
83
  version_requirements: !ruby/object:Gem::Requirement
@@ -87,12 +86,12 @@ dependencies:
87
86
  - !ruby/object:Gem::Version
88
87
  version: '0.22'
89
88
  - !ruby/object:Gem::Dependency
89
+ name: rubocop
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '1.32'
95
- name: rubocop
96
95
  type: :development
97
96
  prerelease: false
98
97
  version_requirements: !ruby/object:Gem::Requirement
@@ -101,26 +100,12 @@ dependencies:
101
100
  - !ruby/object:Gem::Version
102
101
  version: '1.32'
103
102
  - !ruby/object:Gem::Dependency
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: 0.5.0
109
- name: rubocop-packaging
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: 0.5.0
117
- - !ruby/object:Gem::Dependency
103
+ name: rubocop-performance
118
104
  requirement: !ruby/object:Gem::Requirement
119
105
  requirements:
120
106
  - - "~>"
121
107
  - !ruby/object:Gem::Version
122
108
  version: '1.0'
123
- name: rubocop-performance
124
109
  type: :development
125
110
  prerelease: false
126
111
  version_requirements: !ruby/object:Gem::Requirement
@@ -129,12 +114,12 @@ dependencies:
129
114
  - !ruby/object:Gem::Version
130
115
  version: '1.0'
131
116
  - !ruby/object:Gem::Dependency
117
+ name: rubocop-rspec
132
118
  requirement: !ruby/object:Gem::Requirement
133
119
  requirements:
134
120
  - - "~>"
135
121
  - !ruby/object:Gem::Version
136
122
  version: '3.0'
137
- name: rubocop-rspec
138
123
  type: :development
139
124
  prerelease: false
140
125
  version_requirements: !ruby/object:Gem::Requirement
@@ -158,20 +143,15 @@ files:
158
143
  - lib/faraday/gzip.rb
159
144
  - lib/faraday/gzip/middleware.rb
160
145
  - lib/faraday/gzip/version.rb
161
- - spec/faraday/gzip/middleware_spec.rb
162
- - spec/faraday/gzip/version_spec.rb
163
- - spec/spec_helper.rb
164
146
  homepage: https://github.com/bodrovis/faraday-gzip
165
147
  licenses:
166
148
  - MIT
167
149
  metadata:
168
150
  bug_tracker_uri: https://github.com/bodrovis/faraday-gzip/issues
169
151
  changelog_uri: https://github.com/bodrovis/faraday-gzip/blob/master/CHANGELOG.md
170
- documentation_uri: http://www.rubydoc.info/gems/faraday-gzip/3.0.1
171
- homepage_uri: https://github.com/bodrovis/faraday-gzip
152
+ documentation_uri: http://www.rubydoc.info/gems/faraday-gzip/3.0.3
172
153
  source_code_uri: https://github.com/bodrovis/faraday-gzip
173
154
  rubygems_mfa_required: 'true'
174
- post_install_message:
175
155
  rdoc_options: []
176
156
  require_paths:
177
157
  - lib
@@ -186,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
166
  - !ruby/object:Gem::Version
187
167
  version: '0'
188
168
  requirements: []
189
- rubygems_version: 3.3.26
190
- signing_key:
169
+ rubygems_version: 3.6.3
191
170
  specification_version: 4
192
171
  summary: Automatically sets compression headers and decompresses the response
193
172
  test_files: []
@@ -1,179 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Faraday::Gzip::Middleware do
4
- require 'brotli' if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
5
-
6
- subject(:middleware) do
7
- described_class.new(->(env) { Faraday::Response.new(env) })
8
- end
9
-
10
- let(:headers) { {} }
11
-
12
- def process(body, content_type = nil, options = {})
13
- env = {
14
- body: body, request: options,
15
- request_headers: Faraday::Utils::Headers.new,
16
- response_headers: Faraday::Utils::Headers.new(headers)
17
- }
18
- env[:response_headers]['content-type'] = content_type if content_type
19
- yield(env) if block_given?
20
- middleware.call(env)
21
- end
22
-
23
- context 'when request' do
24
- it 'sets the Accept-Encoding request header' do
25
- env = process('').env
26
- encodings = Faraday::Gzip::Middleware::BROTLI_SUPPORTED ? 'gzip,deflate,br' : 'gzip,deflate'
27
- expect(env[:request_headers][:accept_encoding]).to eq(encodings)
28
- end
29
-
30
- it 'doesnt overwrite existing Accept-Encoding request header' do
31
- env = process('') do |e|
32
- e[:request_headers][:accept_encoding] = 'zopfli'
33
- end.env
34
- expect(env[:request_headers][:accept_encoding]).to eq('zopfli')
35
- end
36
- end
37
-
38
- context 'when response' do
39
- let(:uncompressed_body) do
40
- '<html><head><title>Rspec</title></head><body>Hello, spec!</body></html>'
41
- end
42
- let(:empty_body) { '' }
43
- let(:gzipped_body) do
44
- io = StringIO.new
45
- gz = Zlib::GzipWriter.new(io)
46
- gz.write(uncompressed_body)
47
- gz.close
48
- res = io.string
49
- res.force_encoding('BINARY')
50
- res
51
- end
52
- let(:deflated_body) do
53
- Zlib::Deflate.deflate(uncompressed_body)
54
- end
55
- let(:raw_deflated_body) do
56
- z = Zlib::Deflate.new(Zlib::DEFAULT_COMPRESSION, -Zlib::MAX_WBITS)
57
- compressed_body = z.deflate(uncompressed_body, Zlib::FINISH)
58
- z.close
59
- compressed_body
60
- end
61
-
62
- if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
63
- let(:brotlied_body) do
64
- Brotli.deflate(uncompressed_body)
65
- end
66
- end
67
-
68
- shared_examples 'compressed response' do
69
- it 'uncompresses the body' do
70
- expect(process(body).body).to eq(uncompressed_body)
71
- end
72
-
73
- it 'sets the Content-Length' do
74
- expect(process(body).headers['Content-Length']).to eq(uncompressed_body.length)
75
- end
76
-
77
- it 'removes the Content-Encoding' do
78
- expect(process(body).headers['Content-Encoding']).to be_nil
79
- end
80
- end
81
-
82
- context 'when gzipped response' do
83
- let(:body) { gzipped_body }
84
- let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length } }
85
-
86
- it_behaves_like 'compressed response'
87
- end
88
-
89
- context 'when deflated response' do
90
- let(:body) { deflated_body }
91
- let(:headers) { { 'Content-Encoding' => 'deflate', 'Content-Length' => body.length } }
92
-
93
- it_behaves_like 'compressed response'
94
- end
95
-
96
- context 'when raw deflated response' do
97
- let(:body) { raw_deflated_body }
98
- let(:headers) { { 'Content-Encoding' => 'deflate', 'Content-Length' => body.length } }
99
-
100
- it_behaves_like 'compressed response'
101
- end
102
-
103
- if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
104
- context 'when brotlied response' do
105
- let(:body) { brotlied_body }
106
- let(:headers) { { 'Content-Encoding' => 'br', 'Content-Length' => body.length } }
107
-
108
- it_behaves_like 'compressed response'
109
- end
110
- end
111
-
112
- context 'when empty response' do
113
- let(:body) { empty_body }
114
- let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length } }
115
-
116
- it 'sets the Content-Length' do
117
- expect(process(body).headers['Content-Length']).to eq(empty_body.length)
118
- end
119
-
120
- it 'removes the Content-Encoding' do
121
- expect(process(body).headers['Content-Encoding']).to be_nil
122
- end
123
- end
124
-
125
- context 'when nil response' do
126
- let(:body) { nil }
127
- let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => 0 } }
128
-
129
- it 'sets the Content-Length' do
130
- expect(process(body).headers['Content-Length']).to eq(0)
131
- end
132
-
133
- it 'removes the Content-Encoding' do
134
- expect(process(body).headers['Content-Encoding']).to be_nil
135
- end
136
- end
137
-
138
- context 'when identity response' do
139
- let(:body) { uncompressed_body }
140
-
141
- it 'does not modify the body' do
142
- expect(process(body).body).to eq(uncompressed_body)
143
- end
144
- end
145
-
146
- context 'when unsupported encoding response' do
147
- let(:body) { 'unsupported' }
148
- let(:headers) { { 'Content-Encoding' => 'unsupported' } }
149
-
150
- it 'does not modify the body' do
151
- expect(process(body).body).to eq(body)
152
- end
153
-
154
- it 'preserves the Content-Encoding header' do
155
- expect(process(body).headers['Content-Encoding']).to eq('unsupported')
156
- end
157
- end
158
-
159
- context 'when no Content-Encoding header' do
160
- let(:body) { uncompressed_body }
161
- let(:headers) { {} }
162
-
163
- it 'does not modify the body' do
164
- expect(process(body).body).to eq(uncompressed_body)
165
- end
166
-
167
- it 'does not add a Content-Encoding header' do
168
- expect(process(body).headers['Content-Encoding']).to be_nil
169
- end
170
- end
171
-
172
- context 'when Content-Length is a string' do
173
- let(:body) { gzipped_body }
174
- let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length.to_s } }
175
-
176
- it_behaves_like 'compressed response'
177
- end
178
- end
179
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'Faraday::Gzip::VERSION' do
4
- subject { Object.const_get(self.class.description) }
5
-
6
- it { is_expected.to match(/^\d+\.\d+\.\d+(\.\w+(\.\d+)?)?$/) }
7
- end
data/spec/spec_helper.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'faraday'
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- add_filter 'spec/'
8
- add_filter '.github/'
9
- end
10
-
11
- require_relative '../lib/faraday/gzip'
12
-
13
- RSpec.configure do |config|
14
- # Enable flags like --only-failures and --next-failure
15
- config.example_status_persistence_file_path = '.rspec_status'
16
-
17
- # Disable RSpec exposing methods globally on `Module` and `main`
18
- config.disable_monkey_patching!
19
-
20
- config.expect_with :rspec do |c|
21
- c.syntax = :expect
22
- end
23
-
24
- config.order = :random
25
- end