nap 0.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rest/request.rb +12 -7
- metadata +4 -3
data/lib/rest/request.rb
CHANGED
@@ -73,21 +73,26 @@ module REST
|
|
73
73
|
[url.path, url.query].compact.join('?')
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
77
|
-
|
76
|
+
def proxy_env
|
77
|
+
{
|
78
|
+
'http' => ENV['HTTP_PROXY'] || ENV['http_proxy'],
|
79
|
+
'https' => ENV['HTTPS_PROXY'] || ENV['https_proxy']
|
80
|
+
}
|
78
81
|
end
|
79
82
|
|
80
83
|
def proxy_settings
|
81
|
-
|
84
|
+
proxy_env[url.scheme] ? URI.parse(proxy_env[url.scheme]) : nil
|
82
85
|
end
|
83
86
|
|
84
|
-
def
|
85
|
-
|
87
|
+
def http_proxy
|
88
|
+
if settings = proxy_settings
|
89
|
+
Net::HTTP.Proxy(settings.host, settings.port, settings.user, settings.password)
|
90
|
+
end
|
86
91
|
end
|
87
92
|
|
88
93
|
def http_request
|
89
|
-
if
|
90
|
-
|
94
|
+
if http_proxy
|
95
|
+
http_proxy.new(url.host, url.port)
|
91
96
|
else
|
92
97
|
Net::HTTP.new(url.host, url.port)
|
93
98
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Manfred Stienstra
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-14 00:00:00 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
21
|
name: rake
|