metainspector 5.2.3 → 5.3.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: 4aa5c9bf09b480058faab117ba35ad33f8f3f30d
4
- data.tar.gz: 4e960580f5823e775ac993f35158b2ca13e80037
3
+ metadata.gz: cba788277633b21dbd2df7a3487291335b6ae678
4
+ data.tar.gz: ceb4dbfa58b7372c0e13ac0e702ee8a5764df521
5
5
  SHA512:
6
- metadata.gz: 22cab972b2f995f9fd548e6091480e0eac85f8394fe7bf7b9646e6d6f83937d743cb1eac2801a2d17759c18be272a07324159e939c5ebd1e6d98fdbca130299f
7
- data.tar.gz: d08f347686fe5cc9a586615bc42404658c1ffe0ebbf7e25754591e66a0da1a89bc8b31edf6d2a9974a8cb0e0029609373effd30708d53d3228b5c70c96300c0a
6
+ metadata.gz: 59e2fa6c8bc92047c0bfe60645d6e04ccec51f87c60e964683a9c4c8b0ed35821d7a4d2252c780cdd763e81d11b8776d94c2ed8e3dc5701f35259cd4723ff9d1
7
+ data.tar.gz: 8c1220df275bd25570872b6732b541f8f5ab0f5abacdad184234b5f5f2eec665a128b90746003f9642f878dce0a20dd5dc3bf65a2b2c1d07a3843fde46948fa4
@@ -3,6 +3,7 @@ require 'faraday_middleware'
3
3
  require 'faraday-cookie_jar'
4
4
  require 'faraday-http-cache'
5
5
  require 'faraday/encoding'
6
+ require 'timeout'
6
7
 
7
8
  module MetaInspector
8
9
 
@@ -47,34 +48,49 @@ module MetaInspector
47
48
  private
48
49
 
49
50
  def fetch
50
- @faraday_options.merge!(:url => url)
51
+ Timeout::timeout(fatal_timeout) do
52
+ @faraday_options.merge!(:url => url)
51
53
 
52
- session = Faraday.new(@faraday_options) do |faraday|
53
- faraday.request :retry, max: @retries
54
+ session = Faraday.new(@faraday_options) do |faraday|
55
+ faraday.request :retry, max: @retries
54
56
 
55
- if @allow_redirections
56
- faraday.use FaradayMiddleware::FollowRedirects, limit: 10
57
- faraday.use :cookie_jar
57
+ if @allow_redirections
58
+ faraday.use FaradayMiddleware::FollowRedirects, limit: 10
59
+ faraday.use :cookie_jar
60
+ end
61
+
62
+ if @faraday_http_cache.is_a?(Hash)
63
+ @faraday_http_cache[:serializer] ||= Marshal
64
+ faraday.use Faraday::HttpCache, @faraday_http_cache
65
+ end
66
+
67
+ faraday.headers.merge!(@headers || {})
68
+ faraday.response :encoding
69
+ faraday.adapter :net_http
58
70
  end
59
71
 
60
- if @faraday_http_cache.is_a?(Hash)
61
- @faraday_http_cache[:serializer] ||= Marshal
62
- faraday.use Faraday::HttpCache, @faraday_http_cache
72
+ response = session.get do |req|
73
+ req.options.timeout = @connection_timeout
74
+ req.options.open_timeout = @read_timeout
63
75
  end
64
76
 
65
- faraday.headers.merge!(@headers || {})
66
- faraday.response :encoding
67
- faraday.adapter :net_http
68
- end
77
+ @url.url = response.env.url.to_s
69
78
 
70
- response = session.get do |req|
71
- req.options.timeout = @connection_timeout
72
- req.options.open_timeout = @read_timeout
79
+ response
73
80
  end
81
+ rescue Timeout::Error => e
82
+ raise MetaInspector::TimeoutError.new(e)
83
+ end
74
84
 
75
- @url.url = response.env.url.to_s
76
-
77
- response
85
+ # Timeouts when connecting / reading a request are handled by Faraday, but in the
86
+ # case of URLs that respond with streaming, Faraday will never return. In that case,
87
+ # we'll resort to our own timeout
88
+ #
89
+ # https://github.com/jaimeiniesta/metainspector/issues/188
90
+ # https://github.com/lostisland/faraday/issues/602
91
+ #
92
+ def fatal_timeout
93
+ (@connection_timeout || 0) + (@read_timeout || 0) + 1
78
94
  end
79
95
  end
80
96
  end
@@ -1,3 +1,3 @@
1
1
  module MetaInspector
2
- VERSION = '5.2.3'
2
+ VERSION = '5.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metainspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.3
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Iniesta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-27 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri