metainspector 5.2.3 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/meta_inspector/request.rb +35 -19
- data/lib/meta_inspector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cba788277633b21dbd2df7a3487291335b6ae678
|
4
|
+
data.tar.gz: ceb4dbfa58b7372c0e13ac0e702ee8a5764df521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
51
|
+
Timeout::timeout(fatal_timeout) do
|
52
|
+
@faraday_options.merge!(:url => url)
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
+
session = Faraday.new(@faraday_options) do |faraday|
|
55
|
+
faraday.request :retry, max: @retries
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
61
|
-
@
|
62
|
-
|
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
|
-
|
66
|
-
faraday.response :encoding
|
67
|
-
faraday.adapter :net_http
|
68
|
-
end
|
77
|
+
@url.url = response.env.url.to_s
|
69
78
|
|
70
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|