tweakphoeus 0.2.5 → 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/CHANGELOG.md +1 -0
- data/README.md +3 -0
- data/lib/tweakphoeus/version.rb +1 -1
- data/lib/tweakphoeus.rb +14 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc7932bfc55944db175b78337a59df4b85cc72a9
|
4
|
+
data.tar.gz: d0653d3ba555dc2350566feb180bab522454d412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 265cb93e198231d4da9d1b225b38cda425182d509d687873078e82fcdceb3b871e08218408b569fb0b532788237515771fa4b56935cde0346b1bdb11e851c359
|
7
|
+
data.tar.gz: 05c35d848ea2cc788e88ad03065fa197b8e929272e079639c1ebc450ff3de5b40a36e7b15b52640e9b0b072e26cc31354e3b7a8b58ed644bebc2689ad263473a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,9 @@ Tweakphoeus.get(url, headers: hash, body: hash)
|
|
36
36
|
|
37
37
|
TODO: Write usage instructions here
|
38
38
|
|
39
|
+
### Using proxies
|
40
|
+
To use HTTP proxies with optional basic authorization, use `set_proxy(url[, user: <user>, password: <pass>])`. Proxy can be disabled with `unset_proxy`.
|
41
|
+
|
39
42
|
## Development
|
40
43
|
|
41
44
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/tweakphoeus/version.rb
CHANGED
data/lib/tweakphoeus.rb
CHANGED
@@ -15,6 +15,8 @@ module Tweakphoeus
|
|
15
15
|
"Accept-Encoding" => "",
|
16
16
|
"Connection" => "keep-alive"
|
17
17
|
}
|
18
|
+
@proxy = nil
|
19
|
+
@proxyuserpwd = nil
|
18
20
|
end
|
19
21
|
|
20
22
|
def get(url, body: nil, params: nil, headers: nil, redirect: true)
|
@@ -76,13 +78,23 @@ module Tweakphoeus
|
|
76
78
|
cookies.map{ |key, value| "#{key}=#{value}" }.join('; ')
|
77
79
|
end
|
78
80
|
|
81
|
+
def set_proxy(url, auth = nil)
|
82
|
+
@proxyuserpwd = "#{auth[:user]}:#{auth[:password]}" if auth.is_a?(Hash)
|
83
|
+
@proxy = url
|
84
|
+
end
|
85
|
+
|
86
|
+
def unset_proxy
|
87
|
+
@proxyuserpwd = nil
|
88
|
+
@proxy = nil
|
89
|
+
end
|
90
|
+
|
79
91
|
private
|
80
92
|
|
81
|
-
def http_request(url, body: nil, params: nil, headers: nil, redirect: false, method:
|
93
|
+
def http_request(url, body: nil, params: nil, headers: nil, redirect: false, method: :get)
|
82
94
|
request_headers = merge_default_headers(headers)
|
83
95
|
request_headers["Cookie"] = cookie_string(url, headers)
|
84
96
|
request_headers["Referer"] = get_referer
|
85
|
-
response = Typhoeus.send(method, url, body: body, params: params, headers: request_headers)
|
97
|
+
response = Typhoeus.send(method, url, body: body, params: params, headers: request_headers, proxy: @proxy, proxyuserpwd: @proxyuserpwd)
|
86
98
|
obtain_cookies(response)
|
87
99
|
set_referer(url) if method != :post
|
88
100
|
if redirect && has_redirect?(response)
|
@@ -166,6 +178,5 @@ module Tweakphoeus
|
|
166
178
|
def set_referer url
|
167
179
|
@referer.last.replace url
|
168
180
|
end
|
169
|
-
|
170
181
|
end
|
171
182
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweakphoeus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Martin Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.6.
|
123
|
+
rubygems_version: 2.6.11
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Typhoeus on steroids.
|