down 5.4.0 → 5.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +0 -11
- data/down.gemspec +1 -1
- data/lib/down/httpx.rb +5 -3
- data/lib/down/net_http.rb +3 -2
- data/lib/down/utils.rb +1 -1
- data/lib/down/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a87deb869d776663b7fa4a32a87fcf73ffe2434e2fbe4fdef1ce7d6e48cf55
|
4
|
+
data.tar.gz: 294efe7598f57309b0cbc3a3190685663384c9b3374c9afa621e728205bc367e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7d3f067b9de755a9976d572e668cad8d39e38968da71f209a5044debd3b0db14c7f70bf96b4237eae1da73178cdcafd454f28cc1bba34e6d92f02194ee94e0
|
7
|
+
data.tar.gz: 9638590a3e4ee48ccd9c6409aadd140182315a0a648896b52a14fd5419c67bba1a4266cf00e51ec9dca6b17e77520373373ef7693d8155bfeb5409078c3ca9f6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 5.4.2 (2024-04-19)
|
2
|
+
|
3
|
+
* Add support for HTTPX 1.x (@HoneyryderChuck)
|
4
|
+
|
5
|
+
## 5.4.1 (2023-05-20)
|
6
|
+
|
7
|
+
* Handle additional params in `Content-Disposition` header (@janko)
|
8
|
+
|
9
|
+
* Add ability to detect response URI when using net/http (@aglushkov)
|
10
|
+
|
11
|
+
* Avoid deprecation warning in HTTPX (@ollym)
|
12
|
+
|
13
|
+
* Handle unknown response status in net/http backend (@janko)
|
14
|
+
|
1
15
|
## 5.4.0 (2022-12-26)
|
2
16
|
|
3
17
|
* Add new HTTPX backend, which supports HTTP/2 protocol among other features (@HoneyryderChuck)
|
data/README.md
CHANGED
@@ -511,17 +511,6 @@ wget.download("http://nature.com/forest.jpg")
|
|
511
511
|
wget.open("http://nature.com/forest.jpg")
|
512
512
|
```
|
513
513
|
|
514
|
-
## Supported Ruby versions
|
515
|
-
|
516
|
-
* MRI 2.3
|
517
|
-
* MRI 2.4
|
518
|
-
* MRI 2.5
|
519
|
-
* MRI 2.6
|
520
|
-
* MRI 2.7
|
521
|
-
* MRI 3.0
|
522
|
-
* MRI 3.1
|
523
|
-
* JRuby 9.3
|
524
|
-
|
525
514
|
## Development
|
526
515
|
|
527
516
|
Tests require that a [httpbin] server is running locally, which you can do via Docker:
|
data/down.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
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
|
-
spec.add_development_dependency "httpx", "~> 0
|
23
|
+
spec.add_development_dependency "httpx", "~> 0", "< 2.0.0"
|
24
24
|
# http 5.0 drop support of ruby 2.3 and 2.4. We still support those versions.
|
25
25
|
if RUBY_VERSION >= "2.5"
|
26
26
|
spec.add_development_dependency "http", "~> 5.0"
|
data/lib/down/httpx.rb
CHANGED
@@ -14,12 +14,14 @@ module Down
|
|
14
14
|
|
15
15
|
USER_AGENT = "Down/#{Down::VERSION}"
|
16
16
|
|
17
|
+
BASIC_AUTH = HTTPX::VERSION >= "1.0.0" ? :basic_auth : :basic_authentication
|
18
|
+
|
17
19
|
def initialize(**options, &block)
|
18
20
|
@method = options.delete(:method) || :get
|
19
21
|
headers = options.delete(:headers) || {}
|
20
22
|
@client = HTTPX
|
21
23
|
.plugin(:follow_redirects, max_redirects: 2)
|
22
|
-
.plugin(
|
24
|
+
.plugin(BASIC_AUTH)
|
23
25
|
.plugin(:stream)
|
24
26
|
.with(
|
25
27
|
headers: { "user-agent": USER_AGENT }.merge(headers),
|
@@ -128,7 +130,7 @@ module Down
|
|
128
130
|
end
|
129
131
|
client = block.call(client) if block
|
130
132
|
|
131
|
-
client.request(method, uri, stream: true, **options)
|
133
|
+
client.request(method.to_s.upcase, uri, stream: true, **options)
|
132
134
|
rescue => exception
|
133
135
|
request_error!(exception)
|
134
136
|
end
|
@@ -172,4 +174,4 @@ module Down
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
end
|
175
|
-
end
|
177
|
+
end
|
data/lib/down/net_http.rb
CHANGED
@@ -270,7 +270,7 @@ module Down
|
|
270
270
|
headers = options[:headers].to_h
|
271
271
|
headers["Accept-Encoding"] = "" # Net::HTTP's inflater causes FiberErrors
|
272
272
|
|
273
|
-
get = Net::HTTP::Get.new(uri
|
273
|
+
get = Net::HTTP::Get.new(uri, headers)
|
274
274
|
|
275
275
|
user, password = options[:http_basic_authentication] || [uri.user, uri.password]
|
276
276
|
get.basic_auth(user, password) if user || password
|
@@ -312,13 +312,14 @@ module Down
|
|
312
312
|
# rebuild the Net::HTTP response object.
|
313
313
|
def rebuild_response_from_open_uri_exception(exception)
|
314
314
|
code, message = exception.io.status
|
315
|
+
message ||= "Unknown"
|
315
316
|
|
316
317
|
response_class = Net::HTTPResponse::CODE_TO_OBJ.fetch(code) do |c|
|
317
318
|
Net::HTTPResponse::CODE_CLASS_TO_OBJ.fetch(c[0]) do
|
318
319
|
Net::HTTPUnknownResponse
|
319
320
|
end
|
320
321
|
end
|
321
|
-
response
|
322
|
+
response = response_class.new(nil, code, message)
|
322
323
|
|
323
324
|
exception.io.metas.each do |name, values|
|
324
325
|
values.each { |value| response.add_field(name, value) }
|
data/lib/down/utils.rb
CHANGED
@@ -11,7 +11,7 @@ module Down
|
|
11
11
|
escaped_filename =
|
12
12
|
content_disposition[/filename\*=UTF-8''(\S+)/, 1] ||
|
13
13
|
content_disposition[/filename="([^"]*)"/, 1] ||
|
14
|
-
content_disposition[/filename=(
|
14
|
+
content_disposition[/filename=([^\s;]+)/, 1]
|
15
15
|
|
16
16
|
filename = CGI.unescape(escaped_filename.to_s)
|
17
17
|
|
data/lib/down/version.rb
CHANGED
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.4.
|
4
|
+
version: 5.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,20 +72,20 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
76
|
-
- - "
|
75
|
+
version: '0'
|
76
|
+
- - "<"
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.
|
78
|
+
version: 2.0.0
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - "~>"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '0
|
86
|
-
- - "
|
85
|
+
version: '0'
|
86
|
+
- - "<"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0.
|
88
|
+
version: 2.0.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: http
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.5.3
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Robust streaming downloads using Net::HTTP, HTTP.rb or wget.
|