proxy_fetcher 0.8.0 → 0.9.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 +5 -5
- data/CHANGELOG.md +12 -1
- data/lib/proxy_fetcher.rb +2 -1
- data/lib/proxy_fetcher/client/request.rb +1 -1
- data/lib/proxy_fetcher/configuration.rb +19 -4
- data/lib/proxy_fetcher/utils/http_client.rb +8 -1
- data/lib/proxy_fetcher/utils/proxy_validator.rb +1 -1
- data/lib/proxy_fetcher/version.rb +1 -1
- data/proxy_fetcher.gemspec +1 -0
- data/spec/proxy_fetcher/client/client_spec.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d5fee8c7b429b32d608388ddf15885d2354721d6de693396ad228248925cf2d6
|
4
|
+
data.tar.gz: '0250291040c511a723cdae4a22a78d4f765a0ca7b10325f331a8d119f8d25157'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d12b75f0e80075d31832f8add9d1269ae48ff32714a0c0b481a85eb275094ccec62020911d55f74a2920211fc445f11ee3c31f43fdc7cc1f5ae2d175278eec
|
7
|
+
data.tar.gz: 138c464c0531fc12773b995d3101f5e952e2a4868e7e13d18274b27f7b0ea310a515d76e2066f36b25c2586c2046b9497f15a74e943cfbc8fdc8f0204796f93e
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,18 @@ Reverse Chronological Order:
|
|
4
4
|
|
5
5
|
## `master`
|
6
6
|
|
7
|
-
* Add your
|
7
|
+
* Add your description here
|
8
|
+
|
9
|
+
## `0.9.0` (2019-01-22)
|
10
|
+
|
11
|
+
* Fix a problem with stuck of proxies list loading.
|
12
|
+
|
13
|
+
* Add a possibility to configure different timeouts for different cases:
|
14
|
+
- `client_timeout` - timeout for `ProxyFetcher::Client`.
|
15
|
+
- `provider_proxies_load_timeout` - timeout for loading of proxies list by provider.
|
16
|
+
- `proxy_validation_timeout` - timeout for proxy validation with `ProxyFetcher::ProxyValidator`.
|
17
|
+
|
18
|
+
(old option `timeout` sets and returns value of `client_timeout`)
|
8
19
|
|
9
20
|
## `0.8.0` (2018-11-12)
|
10
21
|
|
data/lib/proxy_fetcher.rb
CHANGED
@@ -54,7 +54,8 @@ module ProxyFetcher
|
|
54
54
|
# ProxyFetcher.config
|
55
55
|
#
|
56
56
|
# #=> #<ProxyFetcher::Configuration:0x0000000241eec8 @user_agent="Mozilla/5.0, ...", @pool_size=10,
|
57
|
-
# @
|
57
|
+
# @client_timeout=3, @proxy_validation_timeout=3, @provider_proxies_load_timeout=30,
|
58
|
+
# @http_client=ProxyFetcher::HTTPClient, @proxy_validator=ProxyFetcher::ProxyValidator,
|
58
59
|
# @providers=[:free_proxy_list, ...], @adapter=ProxyFetcher::Document::NokogiriAdapter>
|
59
60
|
#
|
60
61
|
def config
|
@@ -56,7 +56,7 @@ module ProxyFetcher
|
|
56
56
|
@method = args.fetch(:method).to_s.downcase
|
57
57
|
@headers = (args[:headers] || {}).dup
|
58
58
|
@payload = args[:payload]
|
59
|
-
@timeout = args.fetch(:timeout, ProxyFetcher.config.
|
59
|
+
@timeout = args.fetch(:timeout, ProxyFetcher.config.client_timeout)
|
60
60
|
@ssl_options = args.fetch(:ssl_options, default_ssl_options)
|
61
61
|
|
62
62
|
@proxy = args.fetch(:proxy)
|
@@ -5,9 +5,21 @@ module ProxyFetcher
|
|
5
5
|
# with HTTP requests, adapters, custom classes.
|
6
6
|
#
|
7
7
|
class Configuration
|
8
|
-
# @!attribute
|
9
|
-
# @return [Integer] HTTP request
|
10
|
-
attr_accessor :
|
8
|
+
# @!attribute client_timeout
|
9
|
+
# @return [Integer] HTTP request timeout (connect / open) for [ProxyFetcher::Client]
|
10
|
+
attr_accessor :client_timeout
|
11
|
+
|
12
|
+
# @!attribute provider_proxies_load_timeout
|
13
|
+
# @return [Integer] HTTP request timeout (connect / open) for loading of proxies list by provider
|
14
|
+
attr_accessor :provider_proxies_load_timeout
|
15
|
+
|
16
|
+
# @!attribute proxy_validation_timeout
|
17
|
+
# @return [Integer] HTTP request timeout (connect / open) for proxy validation with [ProxyFetcher::ProxyValidator]
|
18
|
+
attr_accessor :proxy_validation_timeout
|
19
|
+
|
20
|
+
# to save compatibility
|
21
|
+
alias timeout client_timeout
|
22
|
+
alias timeout= client_timeout=
|
11
23
|
|
12
24
|
# @!attribute pool_size
|
13
25
|
# @return [Integer] proxy validator pool size (max number of threads)
|
@@ -98,7 +110,10 @@ module ProxyFetcher
|
|
98
110
|
@logger = Logger.new(STDOUT)
|
99
111
|
@user_agent = DEFAULT_USER_AGENT
|
100
112
|
@pool_size = 10
|
101
|
-
@
|
113
|
+
@client_timeout = 3
|
114
|
+
@provider_proxies_load_timeout = 30
|
115
|
+
@proxy_validation_timeout = 3
|
116
|
+
|
102
117
|
@http_client = HTTPClient
|
103
118
|
@proxy_validator = ProxyValidator
|
104
119
|
|
@@ -17,6 +17,10 @@ module ProxyFetcher
|
|
17
17
|
# @return [OpenSSL::SSL::SSLContext] SSL context
|
18
18
|
attr_reader :ssl_ctx
|
19
19
|
|
20
|
+
# @!attribute [r] timeout
|
21
|
+
# @return [Integer] Request timeout
|
22
|
+
attr_reader :timeout
|
23
|
+
|
20
24
|
# Fetches resource content by sending HTTP request to it.
|
21
25
|
# Synthetic sugar to simplify URIes fetching.
|
22
26
|
#
|
@@ -36,6 +40,7 @@ module ProxyFetcher
|
|
36
40
|
def initialize(url)
|
37
41
|
@url = url.to_s
|
38
42
|
@http = HTTP.headers(default_headers)
|
43
|
+
@timeout = ProxyFetcher.config.provider_proxies_load_timeout
|
39
44
|
|
40
45
|
@ssl_ctx = OpenSSL::SSL::SSLContext.new
|
41
46
|
@ssl_ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -47,7 +52,9 @@ module ProxyFetcher
|
|
47
52
|
# response body
|
48
53
|
#
|
49
54
|
def fetch
|
50
|
-
@http.
|
55
|
+
@http.timeout(connect: timeout, read: timeout)
|
56
|
+
.get(url, ssl_context: ssl_ctx)
|
57
|
+
.body.to_s
|
51
58
|
rescue StandardError
|
52
59
|
ProxyFetcher.logger.warn("Failed to load proxy list for #{url}")
|
53
60
|
''
|
@@ -28,7 +28,7 @@ module ProxyFetcher
|
|
28
28
|
# @return [ProxyValidator]
|
29
29
|
#
|
30
30
|
def initialize(proxy_addr, proxy_port)
|
31
|
-
timeout = ProxyFetcher.config.
|
31
|
+
timeout = ProxyFetcher.config.proxy_validation_timeout
|
32
32
|
|
33
33
|
@http = HTTP.follow.via(proxy_addr, proxy_port.to_i).timeout(connect: timeout, read: timeout)
|
34
34
|
end
|
data/proxy_fetcher.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Bulai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
134
|
- !ruby/object:Gem::Version
|
121
135
|
version: '0'
|
122
136
|
requirements: []
|
123
|
-
|
124
|
-
rubygems_version: 2.6.11
|
137
|
+
rubygems_version: 3.0.2
|
125
138
|
signing_key:
|
126
139
|
specification_version: 4
|
127
140
|
summary: Ruby gem for dealing with proxy lists from different providers
|