down 2.3.8 → 2.4.0

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
  SHA1:
3
- metadata.gz: eb93603bdd669c579229eed4924173323351f338
4
- data.tar.gz: 985886e895e1c71328d812df17990c944efe8cb1
3
+ metadata.gz: b9426b78a8ed3171bfc68908bb38bef667cc33d7
4
+ data.tar.gz: 387a0922d85551ca4d9a481fc60a09ae58dde315
5
5
  SHA512:
6
- metadata.gz: 03935d502e94f8a8b681996aa364f13cdee50c84cdc2b9655df2146d31a263bb2319280e9636cef90b8a70f59f5d80004e5ed0620af5085c72e9ed435391b430
7
- data.tar.gz: bcb236b7447b47674c2adcf72047ca37f904f2507ba27e297db60c3869e7728d36b79b0be5f63132c5e9f5227f20fdabfe00bed95fa65e4681501e94df87c8a5
6
+ metadata.gz: 280c33064160408828309a8eb3cc14272ec56806d058f81a4ac8071d04daa9da294162577cffe1e0a3b284a5e32e79d910510fe27060fa3b52cce3ec1e6a1689
7
+ data.tar.gz: 64d4a96f1f4e6da517fc8edebcf7f82a856a3778f14904f9b1ffec46a6a0711bdc78a990ae57946b9ed59d102e6870a6f140c001ee40d99f2171bff3ebcf1cb2
data/README.md CHANGED
@@ -157,6 +157,14 @@ end
157
157
  remote_file.close
158
158
  ```
159
159
 
160
+ It accepts the `:ssl_verify_mode` and `:ssl_ca_cert` options with the same
161
+ semantics as in `open-uri`, and any options with String keys will be
162
+ interpreted as request headers.
163
+
164
+ ```rb
165
+ Down.open("http://example.com/image.jpg", {"Authorization" => "..."})
166
+ ```
167
+
160
168
  ### `Down::ChunkedIO`
161
169
 
162
170
  The `Down.open` method uses `Down::ChunkedIO` internally. However,
@@ -105,9 +105,11 @@ module Down
105
105
  http.cert_store = store
106
106
  end
107
107
 
108
+ request_headers = options.select { |key, value| key.is_a?(String) }
109
+
108
110
  request = Fiber.new do
109
111
  http.start do
110
- http.request_get(uri.request_uri) do |response|
112
+ http.request_get(uri.request_uri, request_headers) do |response|
111
113
  Fiber.yield response
112
114
  response.instance_variable_set("@read", true)
113
115
  end
@@ -164,7 +166,9 @@ module Down
164
166
  private
165
167
 
166
168
  def filename_from_content_disposition
167
- meta["content-disposition"].to_s[/filename="([^"]+)"/, 1]
169
+ content_disposition = meta["content-disposition"].to_s
170
+ filename = content_disposition[/filename="([^"]+)"/, 1] || content_disposition[/filename=(.+)/, 1]
171
+ filename && CGI.unescape(filename.strip)
168
172
  end
169
173
 
170
174
  def filename_from_uri
@@ -1,3 +1,3 @@
1
1
  module Down
2
- VERSION = "2.3.8"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require "down/version"
2
+ require "down/chunked_io"
3
+
4
+ require "open3"
5
+
6
+ module Down
7
+ class Error < StandardError; end
8
+ class TooLarge < Error; end
9
+ class NotFound < Error; end
10
+
11
+ module_function
12
+
13
+ def download(url, options = {})
14
+ max_size = options.delete(:max_size)
15
+ max_redirects = options.delete(:max_redirects) || 2
16
+ progress_proc = options.delete(:progress_proc) || options.delete(:progress)
17
+ content_length_proc = options.delete(:content_length_proc)
18
+ timeout = options.delete(:timeout)
19
+ end
20
+ end
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.8
4
+ version: 2.4.0
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-07 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -93,6 +93,7 @@ files:
93
93
  - lib/down.rb
94
94
  - lib/down/chunked_io.rb
95
95
  - lib/down/version.rb
96
+ - lib/down/wget.rb
96
97
  homepage: https://github.com/janko-m/down
97
98
  licenses:
98
99
  - MIT