http-proxy 0.2.0 → 0.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/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/http-proxy.gemspec +1 -1
- data/lib/http-proxy/chainable.rb +3 -4
- 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: eaeb307b91714f53a84e1b24e5a0160e345f1d7e37dd5b232962b7a5d42d50a2
|
4
|
+
data.tar.gz: 26e0aff91af5bbb357bf92d82c2f259c26fbd380ce927be303bb46d5bfb75b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e954eaa1f88f26bc1247771ad6f8cc02160f09d284ca7515956dc81391e81495165f64405ad2892de43f69a4affd010b048c808c8578d1d07bbeebb328f12d
|
7
|
+
data.tar.gz: f53b8d3430ce567b57ddce1a9466a85be309ec190731d24bf3c8db420821b3e0f4549d16d5856f27cb1e3b0b4db2bc16504933c6960c4edd5c9b5868c8b6420b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# HTTP::Proxy
|
2
|
+
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fzt2%2Fhttp-proxy?ref=badge_shield)
|
3
|
+
|
2
4
|
|
3
5
|
HTTP::Proxy allows you sending HTTP request via proxy automatically. This library extends gem HTTP by patching HTTP::Chainable to make proxy http request possible.
|
4
6
|
|
@@ -33,6 +35,12 @@ HTTP.proxy.get 'https://httpbin.org/ip'
|
|
33
35
|
# => {"origin"=>"36.83.40.184, 36.83.40.184"}
|
34
36
|
```
|
35
37
|
|
38
|
+
With any condition in block (see more in [ProxyPool](https://github.com/zt2/ProxyPool))
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
HTTP.proxy { |proxy| proxy['country'] == 'US' && proxy['response_time'] < 2 }.get
|
42
|
+
```
|
43
|
+
|
36
44
|
## Development
|
37
45
|
|
38
46
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -41,7 +49,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
41
49
|
|
42
50
|
## Contributing
|
43
51
|
|
44
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zt2/http-proxy.
|
45
53
|
|
46
54
|
## License
|
47
55
|
|
data/http-proxy.gemspec
CHANGED
data/lib/http-proxy/chainable.rb
CHANGED
@@ -6,17 +6,16 @@ module HTTP
|
|
6
6
|
# Choose a proxy to send HTTP request
|
7
7
|
#
|
8
8
|
# @param anonymous [Boolean] Using anonymous proxy or not
|
9
|
-
def proxy(anonymous = true)
|
9
|
+
def proxy(anonymous = true, &block)
|
10
10
|
if anonymous
|
11
11
|
p = ProxyPool.get_high_anonymous_proxy
|
12
|
+
elsif block_given?
|
13
|
+
p = ProxyPool.get(&block)
|
12
14
|
else
|
13
15
|
p = ProxyPool.get
|
14
16
|
end
|
15
17
|
|
16
18
|
via(p['host'], p['port'])
|
17
|
-
rescue HTTP::ConnectionError
|
18
|
-
ProxyPool.remove(p)
|
19
|
-
retry
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hi_ztz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|