url_fetcher 1.1.6 → 1.1.7

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
- SHA1:
3
- metadata.gz: 8523decc234223ef23d0ad21e091b8e02b10697d
4
- data.tar.gz: 54d317200ebbd7921eef0def888b0932a23a2f2f
2
+ SHA256:
3
+ metadata.gz: 40fafbb372a909feae773b1e7908aebd79b77988b7d1b161f3cf54ee9a90bd37
4
+ data.tar.gz: 0c6596f02ff0b78c123447c44f656cbd4c6a742fa6532a61c4544095ead36e37
5
5
  SHA512:
6
- metadata.gz: 82a6284bcd4a7096f8828b950431adb7940d2c9c2ad1b8e932ce16bf912ba4dac5fde62065c93ba4045028b97f8b8415f6fccb5de8fdebd0a6ebec56c26e5674
7
- data.tar.gz: ad131782b83ac319e3819139c278f8f705c4c9a8f36705a1418aa494d54669521a2c64bde94dab23fa2990750504d3b4844d4e6714e55d2dbef494ad5c804e44
6
+ metadata.gz: 6f40b40f4eca2c555495033453ea6ea063bf44e0886565a6e2f3d26f716b63f0d6484a45afa4d469d39c7bec400ce6ae5d6bae9378dbd1c3127e716f0c3ad051
7
+ data.tar.gz: b29f096c78f65550cc329beb5eb4944195aaeb6eb927d9e8519428eb813a1eac94c48ac01a011984790ee348095ba41856f783d653c6cb643b1a5d108dc6adc3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.6
1
+ 1.1.7
@@ -34,11 +34,11 @@ class UrlFetcher
34
34
  def body
35
35
  @response.body if success?
36
36
  end
37
-
37
+
38
38
  def close
39
39
  body.close if body && !body.closed?
40
40
  end
41
-
41
+
42
42
  def closed?
43
43
  body.closed? if body
44
44
  end
@@ -100,12 +100,12 @@ class UrlFetcher
100
100
  name = name.to_s
101
101
  values = Array(value)
102
102
  request[name] = values[0].to_s
103
- values[1, values.length].each do |val|
103
+ values[1, values.length].each do |val|
104
104
  request.add_field(name, val.to_s)
105
105
  end
106
106
  end
107
107
  end
108
-
108
+
109
109
  response = http.request(request) do |resp|
110
110
  unless resp.is_a?(Net::HTTPSuccess) || resp.is_a?(Net::HTTPRedirection)
111
111
  resp.value # Raises an appropriate HTTP error
@@ -113,7 +113,8 @@ class UrlFetcher
113
113
  if resp.is_a?(Net::HTTPSuccess) && resp.class.body_permitted?
114
114
  content_length = resp["Content-Length"].to_i
115
115
  raise FileTooBig.new(content_length) if content_length > (options[:max_size] || 10 * MEGABYTE)
116
- ext = File.extname(url)
116
+ ext = File.extname(url.sub(/\?.*/, ''))
117
+ ext = nil if ext && ext.size > 12
117
118
  tempfile = Tempfile.new(["url_fetcher", ext], :encoding => 'ascii-8bit')
118
119
  resp.read_body(tempfile)
119
120
  tempfile.rewind
@@ -32,7 +32,7 @@ describe UrlFetcher do
32
32
  expect(url_fetcher).to be_success
33
33
  expect(url_fetcher).not_to be_redirect
34
34
  expect(url_fetcher.header("content-length")).to eql("5")
35
- expect(url_fetcher.body).to be_nil
35
+ expect(url_fetcher.body.read).to eq ""
36
36
  end
37
37
 
38
38
  it "should work with SSL" do
@@ -43,7 +43,7 @@ describe UrlFetcher do
43
43
  expect(url_fetcher.header("content-length")).to eql("5")
44
44
  expect(url_fetcher.body.read).to eql("Hello")
45
45
  end
46
-
46
+
47
47
  it "should send custom headers" do
48
48
  WebMock.stub_request(:get, "https://example.com/test").with(:headers => {"Accept" => ["image/jpeg", "image/gif"]}).to_return(:status => 200, :body => "Hello", :headers => {"Content-Length" => 5})
49
49
  url_fetcher = UrlFetcher.new("https://example.com/test", :headers => {"Accept" => ["image/jpeg", "image/gif"]})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - weheartit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-03 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.5
123
+ rubygems_version: 2.7.6
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Fetch resources from the internetz with circular redirects support