down 2.3.7 → 2.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/down.gemspec +1 -0
- data/lib/down.rb +24 -5
- data/lib/down/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb93603bdd669c579229eed4924173323351f338
|
4
|
+
data.tar.gz: 985886e895e1c71328d812df17990c944efe8cb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03935d502e94f8a8b681996aa364f13cdee50c84cdc2b9655df2146d31a263bb2319280e9636cef90b8a70f59f5d80004e5ed0620af5085c72e9ed435391b430
|
7
|
+
data.tar.gz: bcb236b7447b47674c2adcf72047ca37f904f2507ba27e297db60c3869e7728d36b79b0be5f63132c5e9f5227f20fdabfe00bed95fa65e4681501e94df87c8a5
|
data/down.gemspec
CHANGED
@@ -16,5 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.add_development_dependency "rake"
|
17
17
|
spec.add_development_dependency "minitest", "~> 5.8"
|
18
18
|
spec.add_development_dependency "webmock"
|
19
|
+
spec.add_development_dependency "addressable", "< 2.5"
|
19
20
|
spec.add_development_dependency "mocha"
|
20
21
|
end
|
data/lib/down.rb
CHANGED
@@ -116,11 +116,30 @@ module Down
|
|
116
116
|
|
117
117
|
response = request.resume
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
if response.chunked?
|
120
|
+
# Net::HTTP's implementation of reading "Transfer-Encoding: chunked"
|
121
|
+
# raises a Fiber error, so we work around it by downloading the whole
|
122
|
+
# response body without Enumerators (which internally use Fibers).
|
123
|
+
warn "Response from #{url} returned as \"Transfer-Encoding: chunked\", which Down cannot partially download, so the whole response body will be downloaded instead."
|
124
|
+
|
125
|
+
tempfile = Tempfile.new("down", binmode: true)
|
126
|
+
response.read_body { |chunk| tempfile << chunk }
|
127
|
+
tempfile.rewind
|
128
|
+
|
129
|
+
request.resume # close HTTP connection
|
130
|
+
|
131
|
+
ChunkedIO.new(
|
132
|
+
chunks: Enumerator.new { |y| y << tempfile.read(16*1024) until tempfile.eof? },
|
133
|
+
size: tempfile.size,
|
134
|
+
on_close: -> { tempfile.close! },
|
135
|
+
)
|
136
|
+
else
|
137
|
+
ChunkedIO.new(
|
138
|
+
chunks: response.enum_for(:read_body),
|
139
|
+
size: response["Content-Length"] && response["Content-Length"].to_i,
|
140
|
+
on_close: -> { request.resume }, # close HTTP connnection
|
141
|
+
)
|
142
|
+
end
|
124
143
|
end
|
125
144
|
|
126
145
|
def copy_to_tempfile(basename, io)
|
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: 2.3.
|
4
|
+
version: 2.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: addressable
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.5'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mocha
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|