http_utilities 1.3.2 → 1.3.3
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/VERSION +1 -1
- data/http_utilities.gemspec +1 -1
- data/lib/http_utilities/http/client.rb +1 -1
- data/lib/http_utilities/http/proxy_support.rb +15 -14
- data/lib/http_utilities/http/request.rb +2 -2
- data/lib/http_utilities.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24370403c5f8396cac1f6fbf76af2bfce33b594d494725f11f4b7dd7e54763a5
|
4
|
+
data.tar.gz: f0e387ec4cfc14c5caa1edf1041c393b0b1aec7a2242fd666e5a595e843522ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c7226e7d4d2a7aa535e86bc6f19f83bfc9a2d127ae2c33ee7ff417dbb53f10ddf3ef5148560e7b9241c37dcd2536c3aadd7df9fda5b9a2c41b49737a3bba9e
|
7
|
+
data.tar.gz: c227b8881310827ab34b7ab3a4c50c118c668021afccd8573010c4be89067104a5d15d3d5d6a8bb24bcb7c6caf4a8cd4ee2850c570162fbb91995a9f9a466086
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
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.3.
|
6
|
+
s.version = "1.3.3"
|
7
7
|
|
8
8
|
s.authors = ["Sebastian Johnsson"]
|
9
9
|
s.description = "Wrapper for Faraday with additional functionality"
|
@@ -56,7 +56,7 @@ module HttpUtilities
|
|
56
56
|
request.set_proxy_options(options)
|
57
57
|
|
58
58
|
proxy_options = request.generate_proxy_options
|
59
|
-
client_options = client_options.merge(proxy: proxy_options)
|
59
|
+
client_options = client_options.merge(proxy: proxy_options) if proxy_options && !proxy_options.empty?
|
60
60
|
|
61
61
|
connection = Faraday.new(client_options) do |builder|
|
62
62
|
builder.headers[:user_agent] = request.user_agent
|
@@ -14,8 +14,7 @@ module HttpUtilities
|
|
14
14
|
proxy_protocol = options.fetch(:proxy_protocol, :all)
|
15
15
|
|
16
16
|
if use_proxy || specific_proxy
|
17
|
-
self.proxy
|
18
|
-
self.proxy[:type] = proxy_type
|
17
|
+
self.proxy ||= {}
|
19
18
|
|
20
19
|
if specific_proxy && specific_proxy.is_a?(String)
|
21
20
|
specific_proxy = specific_proxy.gsub(/^http(s)?:\/\//i, "")
|
@@ -34,7 +33,7 @@ module HttpUtilities
|
|
34
33
|
if specific_proxy && specific_proxy.is_a?(::Proxy)
|
35
34
|
proxy_object = specific_proxy
|
36
35
|
else
|
37
|
-
proxy_object = ::Proxy.get_random_proxy(protocol:
|
36
|
+
proxy_object = ::Proxy.get_random_proxy(protocol: proxy_protocol, proxy_type: proxy_type)
|
38
37
|
end
|
39
38
|
|
40
39
|
#log(:info, "[HttpUtilities::Http::ProxySupport] - Randomized Proxy object: #{proxy_object.inspect}")
|
@@ -42,13 +41,13 @@ module HttpUtilities
|
|
42
41
|
if proxy_object
|
43
42
|
self.proxy[:host] = proxy_object.host
|
44
43
|
self.proxy[:port] = proxy_object.port
|
45
|
-
proxy_username = proxy_object.username.
|
46
|
-
proxy_password = proxy_object.password.
|
44
|
+
proxy_username = !proxy_object.username.to_s.empty? ? proxy_object.username : nil
|
45
|
+
proxy_password = !proxy_object.password.to_s.empty? ? proxy_object.password : nil
|
47
46
|
end
|
48
47
|
end
|
48
|
+
|
49
|
+
set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
|
49
50
|
end
|
50
|
-
|
51
|
-
set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
|
52
51
|
end
|
53
52
|
|
54
53
|
def set_proxy_credentials(proxy_username, proxy_password, proxy_credentials)
|
@@ -73,22 +72,24 @@ module HttpUtilities
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def proxy_model_defined?
|
76
|
-
defined
|
77
|
-
defined
|
75
|
+
defined = Module.const_get("Proxy").is_a?(Class) rescue false
|
76
|
+
defined = (defined && ::Proxy.respond_to?(:get_random_proxy))
|
78
77
|
|
79
78
|
return defined
|
80
79
|
end
|
81
80
|
|
82
81
|
def generate_proxy_options
|
83
|
-
proxy_options
|
82
|
+
proxy_options = {}
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
if !self.proxy[:host].to_s.empty? && !self.proxy[:port].to_s.empty?
|
85
|
+
proxy_options[:uri] = "http://#{self.proxy[:host]}:#{self.proxy[:port]}"
|
86
|
+
proxy_options[:user] = self.proxy[:username] if !self.proxy[:username].to_s.empty?
|
87
|
+
proxy_options[:password] = self.proxy[:password] if !self.proxy[:password].to_s.empty?
|
88
|
+
end
|
88
89
|
|
89
90
|
return proxy_options
|
90
91
|
end
|
91
92
|
|
92
93
|
end
|
93
94
|
end
|
94
|
-
end
|
95
|
+
end
|
@@ -7,7 +7,7 @@ module HttpUtilities
|
|
7
7
|
|
8
8
|
attr_accessor :interface, :proxy, :user_agent
|
9
9
|
|
10
|
-
def initialize(interface: nil, proxy:
|
10
|
+
def initialize(interface: nil, proxy: nil, options: {})
|
11
11
|
self.interface = interface
|
12
12
|
self.proxy = proxy
|
13
13
|
|
@@ -16,4 +16,4 @@ module HttpUtilities
|
|
16
16
|
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
data/lib/http_utilities.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_utilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Johnsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|