http_utilities 1.2.6 → 1.2.6.1
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/http_utilities.gemspec +1 -1
- data/lib/http_utilities.rb +1 -1
- data/lib/http_utilities/http/mechanize/client.rb +8 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 341cc773efe23ad3341ea0ee0a02c3c1548a3eb3
|
4
|
+
data.tar.gz: 1397aea28cc77b53b450b968d526c9ec4f2bcdbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2483b4d8c30eb049ec087b9be3c39dc1ae53b08e7daf0a1134931c25d647fae525ad26b35b907cbb6fea1de9d6baf20f90c4c52b356e302c73824c0caea6176
|
7
|
+
data.tar.gz: ab895796539ebcf6ef156c8abee82c163cc5304b27c7eb14de2df8d76249779733571470e8c9d4e29dc696befb5384f240f4a0d3a86bafcaa78eed4972611894
|
data/http_utilities.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = "http_utilities"
|
6
|
-
s.version = "1.2.6"
|
6
|
+
s.version = "1.2.6.1"
|
7
7
|
|
8
8
|
s.authors = ["Sebastian Johnsson"]
|
9
9
|
s.description = "Wrapper for Faraday with additional functionality"
|
data/lib/http_utilities.rb
CHANGED
@@ -22,9 +22,10 @@ module HttpUtilities
|
|
22
22
|
self.agent = ::Mechanize.new
|
23
23
|
self.agent.log = ::Logger.new(logger) if (verbose)
|
24
24
|
|
25
|
+
self.proxy = {}
|
25
26
|
self.set_proxy_options(options)
|
26
27
|
|
27
|
-
if
|
28
|
+
if self.proxy[:host] && self.proxy[:port]
|
28
29
|
log(:info, "[HttpUtilities::Http::Mechanize::Client] - Will use proxy #{self.proxy[:host]}:#{self.proxy[:port]} for Mechanize.")
|
29
30
|
self.agent.set_proxy(self.proxy[:host], self.proxy[:port], self.proxy[:username], self.proxy[:password])
|
30
31
|
end
|
@@ -33,7 +34,7 @@ module HttpUtilities
|
|
33
34
|
(self.user_agent) ? self.agent.user_agent = self.user_agent : self.agent.user_agent_alias = 'Mac Safari'
|
34
35
|
|
35
36
|
timeout = options.fetch(:timeout, 300)
|
36
|
-
self.agent.open_timeout = self.agent.read_timeout = timeout if
|
37
|
+
self.agent.open_timeout = self.agent.read_timeout = timeout if timeout
|
37
38
|
end
|
38
39
|
|
39
40
|
def reset_agent(options = {})
|
@@ -50,7 +51,7 @@ module HttpUtilities
|
|
50
51
|
rescue Net::HTTPNotFound, ::Mechanize::ResponseCodeError => error
|
51
52
|
log(:error, "[HttpUtilities::Http::Mechanize::Client] - Response Code Error occurred for url #{url}. Error class: #{error.class.name}. Error message: #{error.message}")
|
52
53
|
|
53
|
-
if
|
54
|
+
if retries > 0
|
54
55
|
reset_agent(options)
|
55
56
|
retries -= 1
|
56
57
|
retry
|
@@ -59,7 +60,7 @@ module HttpUtilities
|
|
59
60
|
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Errno::ECONNRESET, Timeout::Error, Net::HTTPUnauthorized, Net::HTTPForbidden, StandardError => connection_error
|
60
61
|
log(:error, "[HttpUtilities::Http::Mechanize::Client] - Error occurred. Error class: #{connection_error.class.name}. Message: #{connection_error.message}")
|
61
62
|
|
62
|
-
if
|
63
|
+
if retries > 0
|
63
64
|
reset_agent(options)
|
64
65
|
retries -= 1
|
65
66
|
retry
|
@@ -88,8 +89,8 @@ module HttpUtilities
|
|
88
89
|
index = form_identifier.delete(:index) { |el| 0 }
|
89
90
|
page = (url_or_page.is_a?(String)) ? get_page(url_or_page, options) : url_or_page
|
90
91
|
|
91
|
-
if
|
92
|
-
if
|
92
|
+
if page
|
93
|
+
if form_identifier.empty?
|
93
94
|
form = page.forms[index]
|
94
95
|
else
|
95
96
|
forms = page.forms_with(form_identifier)
|
@@ -191,4 +192,4 @@ module HttpUtilities
|
|
191
192
|
|
192
193
|
end
|
193
194
|
end
|
194
|
-
end
|
195
|
+
end
|