down 5.2.0 → 5.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +6 -5
- data/down.gemspec +8 -3
- data/lib/down/errors.rb +3 -0
- data/lib/down/http.rb +3 -3
- data/lib/down/net_http.rb +16 -10
- data/lib/down/version.rb +1 -1
- data/lib/down/wget.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9fc55f0895c397eb0ebe2096c09962ac64beb208565e0602088bbe77250e6cd
|
4
|
+
data.tar.gz: e988a2af579a4f728fc1f24f7d32aab4e617b777516c8f2cb7c204606a62b444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a64b2b56f04640bf9255ae20bec88cc4f65f6a862d040197383972240679fdcf1a0434101cc91d0482f2ad4b3dc0356a3c41d1315ff5673aa4fc73fb168380e
|
7
|
+
data.tar.gz: e967d81189426102f33c10a1d7105f1c4df436efedf83f3288890ccc8b75cb85506589ab2a6c895f500467fa1103c7ac678c701e76c3d8722239fc999eb0f850
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,26 @@
|
|
1
|
+
## 5.2.4 (2021-09-12)
|
2
|
+
|
3
|
+
* Keep original cookies between redirections (@antprt)
|
4
|
+
|
5
|
+
## 5.2.3 (2021-08-03)
|
6
|
+
|
7
|
+
* Bump addressable version requirement to 2.8+ to remediate vulnerability (@aldodelgado)
|
8
|
+
|
9
|
+
## 5.2.2 (2021-05-27)
|
10
|
+
|
11
|
+
* Add info about received content length in `Down::TooLarge` error (@evheny0)
|
12
|
+
|
13
|
+
* Relax http.rb constraint to allow versions 5.x (@mgrunberg)
|
14
|
+
|
15
|
+
## 5.2.1 (2021-04-26)
|
16
|
+
|
17
|
+
* Raise `Down::NotModified` on 304 response status in `Down::NetHttp#open` (@ellafeldmann)
|
18
|
+
|
1
19
|
## 5.2.0 (2020-09-20)
|
2
20
|
|
3
21
|
* Add `:uri_normalizer` option to `Down::NetHttp` (@janko)
|
4
22
|
|
5
|
-
* Add `:http_basic_authentication` option to `Down::NetHttp#
|
23
|
+
* Add `:http_basic_authentication` option to `Down::NetHttp#open` (@janko)
|
6
24
|
|
7
25
|
* Fix uninitialized instance variables warnings in `Down::ChunkedIO` (@janko)
|
8
26
|
|
data/README.md
CHANGED
@@ -212,6 +212,7 @@ the `Down::Error` subclasses. This is Down's exception hierarchy:
|
|
212
212
|
* `Down::TooLarge`
|
213
213
|
* `Down::InvalidUrl`
|
214
214
|
* `Down::TooManyRedirects`
|
215
|
+
* `Down::NotModified`
|
215
216
|
* `Down::ResponseError`
|
216
217
|
* `Down::ClientError`
|
217
218
|
* `Down::NotFound`
|
@@ -251,10 +252,10 @@ Down.open("...")
|
|
251
252
|
### Down::NetHttp
|
252
253
|
|
253
254
|
The `Down::NetHttp` backend implements downloads using [open-uri] and
|
254
|
-
[Net::HTTP].
|
255
|
+
[Net::HTTP] standard libraries.
|
255
256
|
|
256
257
|
```rb
|
257
|
-
gem "down", "~>
|
258
|
+
gem "down", "~> 5.0"
|
258
259
|
```
|
259
260
|
```rb
|
260
261
|
require "down/net_http"
|
@@ -370,8 +371,8 @@ net_http.open("http://example.com/image.jpg")
|
|
370
371
|
The `Down::Http` backend implements downloads using the [http.rb] gem.
|
371
372
|
|
372
373
|
```rb
|
373
|
-
gem "down", "~>
|
374
|
-
gem "http", "~>
|
374
|
+
gem "down", "~> 5.0"
|
375
|
+
gem "http", "~> 5.0"
|
375
376
|
```
|
376
377
|
```rb
|
377
378
|
require "down/http"
|
@@ -440,7 +441,7 @@ The `Down::Wget` backend implements downloads using the `wget` command line
|
|
440
441
|
utility.
|
441
442
|
|
442
443
|
```rb
|
443
|
-
gem "down", "~>
|
444
|
+
gem "down", "~> 5.0"
|
444
445
|
gem "posix-spawn" # omit if on JRuby
|
445
446
|
gem "http_parser.rb"
|
446
447
|
```
|
data/down.gemspec
CHANGED
@@ -15,14 +15,19 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "*.gemspec", "lib/**/*.rb"]
|
16
16
|
spec.require_path = "lib"
|
17
17
|
|
18
|
-
spec.add_dependency "addressable", "~> 2.
|
18
|
+
spec.add_dependency "addressable", "~> 2.8"
|
19
19
|
|
20
20
|
spec.add_development_dependency "minitest", "~> 5.8"
|
21
21
|
spec.add_development_dependency "mocha", "~> 1.5"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
|
23
|
+
# http 5.0 drop support of ruby 2.3 and 2.4. We still support those versions.
|
24
|
+
if RUBY_VERSION >= "2.5"
|
25
|
+
spec.add_development_dependency "http", "~> 5.0"
|
26
|
+
else
|
27
|
+
spec.add_development_dependency "http", "~> 4.3"
|
28
|
+
end
|
24
29
|
spec.add_development_dependency "posix-spawn" unless RUBY_ENGINE == "jruby"
|
25
|
-
spec.add_development_dependency "http_parser.rb"
|
30
|
+
spec.add_development_dependency "http_parser.rb" unless RUBY_ENGINE == "jruby"
|
26
31
|
spec.add_development_dependency "docker-api"
|
27
32
|
spec.add_development_dependency "warning" if RUBY_VERSION >= "2.4"
|
28
33
|
end
|
data/lib/down/errors.rb
CHANGED
@@ -13,6 +13,9 @@ module Down
|
|
13
13
|
# raised when the number of redirects was larger than the specified maximum
|
14
14
|
class TooManyRedirects < Error; end
|
15
15
|
|
16
|
+
# raised when the requested resource has not been modified
|
17
|
+
class NotModified < Error; end
|
18
|
+
|
16
19
|
# raised when response returned 4xx or 5xx response
|
17
20
|
class ResponseError < Error
|
18
21
|
attr_reader :response
|
data/lib/down/http.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
2
|
|
3
|
-
gem "http", ">= 2.1.0", "<
|
3
|
+
gem "http", ">= 2.1.0", "< 6"
|
4
4
|
|
5
5
|
require "http"
|
6
6
|
|
@@ -31,7 +31,7 @@ module Down
|
|
31
31
|
content_length_proc.call(response.content_length) if content_length_proc && response.content_length
|
32
32
|
|
33
33
|
if max_size && response.content_length && response.content_length > max_size
|
34
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
34
|
+
raise Down::TooLarge, "file is too large (#{response.content_length/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
35
35
|
end
|
36
36
|
|
37
37
|
extname = File.extname(response.uri.path)
|
@@ -44,7 +44,7 @@ module Down
|
|
44
44
|
progress_proc.call(tempfile.size) if progress_proc
|
45
45
|
|
46
46
|
if max_size && tempfile.size > max_size
|
47
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
47
|
+
raise Down::TooLarge, "file is too large (#{tempfile.size/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
data/lib/down/net_http.rb
CHANGED
@@ -49,13 +49,13 @@ module Down
|
|
49
49
|
open_uri_options = {
|
50
50
|
content_length_proc: proc { |size|
|
51
51
|
if size && max_size && size > max_size
|
52
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
52
|
+
raise Down::TooLarge, "file is too large (#{size/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
53
53
|
end
|
54
54
|
content_length_proc.call(size) if content_length_proc
|
55
55
|
},
|
56
56
|
progress_proc: proc { |current_size|
|
57
57
|
if max_size && current_size > max_size
|
58
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
58
|
+
raise Down::TooLarge, "file is too large (#{current_size/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
59
59
|
end
|
60
60
|
progress_proc.call(current_size) if progress_proc
|
61
61
|
},
|
@@ -158,7 +158,11 @@ module Down
|
|
158
158
|
|
159
159
|
# forward cookies on the redirect
|
160
160
|
if !exception.io.meta["set-cookie"].to_s.empty?
|
161
|
-
options["Cookie"]
|
161
|
+
options["Cookie"] ||= ''
|
162
|
+
# Add new cookies avoiding duplication
|
163
|
+
new_cookies = exception.io.meta["set-cookie"].to_s.split(',').map(&:strip)
|
164
|
+
old_cookies = options["Cookie"].split(',')
|
165
|
+
options["Cookie"] = (old_cookies | new_cookies).join(',')
|
162
166
|
end
|
163
167
|
|
164
168
|
follows_remaining -= 1
|
@@ -202,13 +206,13 @@ module Down
|
|
202
206
|
|
203
207
|
begin
|
204
208
|
response = http.start do
|
205
|
-
http.request(request) do |
|
206
|
-
unless
|
207
|
-
yield
|
209
|
+
http.request(request) do |resp|
|
210
|
+
unless resp.is_a?(Net::HTTPRedirection)
|
211
|
+
yield resp
|
208
212
|
# In certain cases the caller wants to download only one portion
|
209
213
|
# of the file and close the connection, so we tell Net::HTTP that
|
210
214
|
# it shouldn't continue retrieving it.
|
211
|
-
|
215
|
+
resp.instance_variable_set("@read", true)
|
212
216
|
end
|
213
217
|
end
|
214
218
|
end
|
@@ -216,7 +220,9 @@ module Down
|
|
216
220
|
request_error!(exception)
|
217
221
|
end
|
218
222
|
|
219
|
-
if response.is_a?(Net::
|
223
|
+
if response.is_a?(Net::HTTPNotModified)
|
224
|
+
raise Down::NotModified
|
225
|
+
elsif response.is_a?(Net::HTTPRedirection)
|
220
226
|
raise Down::TooManyRedirects if follows_remaining == 0
|
221
227
|
|
222
228
|
# fail if redirect URI is not a valid http or https URL
|
@@ -308,8 +314,8 @@ module Down
|
|
308
314
|
def rebuild_response_from_open_uri_exception(exception)
|
309
315
|
code, message = exception.io.status
|
310
316
|
|
311
|
-
response_class = Net::HTTPResponse::CODE_TO_OBJ.fetch(code) do |
|
312
|
-
Net::HTTPResponse::CODE_CLASS_TO_OBJ.fetch(
|
317
|
+
response_class = Net::HTTPResponse::CODE_TO_OBJ.fetch(code) do |c|
|
318
|
+
Net::HTTPResponse::CODE_CLASS_TO_OBJ.fetch(c[0]) do
|
313
319
|
Net::HTTPUnknownResponse
|
314
320
|
end
|
315
321
|
end
|
data/lib/down/version.rb
CHANGED
data/lib/down/wget.rb
CHANGED
@@ -35,7 +35,7 @@ module Down
|
|
35
35
|
content_length_proc.call(io.size) if content_length_proc && io.size
|
36
36
|
|
37
37
|
if max_size && io.size && io.size > max_size
|
38
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
38
|
+
raise Down::TooLarge, "file is too large (#{io.size/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
39
39
|
end
|
40
40
|
|
41
41
|
extname = File.extname(URI(url).path)
|
@@ -49,7 +49,7 @@ module Down
|
|
49
49
|
progress_proc.call(tempfile.size) if progress_proc
|
50
50
|
|
51
51
|
if max_size && tempfile.size > max_size
|
52
|
-
raise Down::TooLarge, "file is too large (max is #{max_size/1024/1024}MB)"
|
52
|
+
raise Down::TooLarge, "file is too large (#{tempfile.size/1024/1024}MB, max is #{max_size/1024/1024}MB)"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: down
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '5.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '5.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: posix-spawn
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- janko.marohnic@gmail.com
|
142
142
|
executables: []
|
@@ -160,7 +160,7 @@ homepage: https://github.com/janko/down
|
|
160
160
|
licenses:
|
161
161
|
- MIT
|
162
162
|
metadata: {}
|
163
|
-
post_install_message:
|
163
|
+
post_install_message:
|
164
164
|
rdoc_options: []
|
165
165
|
require_paths:
|
166
166
|
- lib
|
@@ -175,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
179
|
-
signing_key:
|
178
|
+
rubygems_version: 3.2.15
|
179
|
+
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Robust streaming downloads using Net::HTTP, HTTP.rb or wget.
|
182
182
|
test_files: []
|