td-client 0.8.23 → 0.8.24
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/lib/td/client/api.rb +17 -16
- data/lib/td/client/version.rb +1 -1
- metadata +1 -1
data/ChangeLog
CHANGED
data/lib/td/client/api.rb
CHANGED
@@ -20,6 +20,10 @@ class API
|
|
20
20
|
require 'json'
|
21
21
|
require 'time'
|
22
22
|
require 'uri'
|
23
|
+
require 'net/http'
|
24
|
+
require 'net/https'
|
25
|
+
require 'time'
|
26
|
+
|
23
27
|
@apikey = apikey
|
24
28
|
|
25
29
|
endpoint = opts[:endpoint] || ENV['TD_API_SERVER'] || 'api.treasure-data.com'
|
@@ -50,6 +54,18 @@ class API
|
|
50
54
|
end
|
51
55
|
@base_path = ''
|
52
56
|
end
|
57
|
+
|
58
|
+
@http_proxy = opts[:http_proxy] || ENV['HTTP_PROXY']
|
59
|
+
if @http_proxy = ENV['HTTP_PROXY']
|
60
|
+
if @http_proxy =~ /\Ahttp:\/\/(.*)\z/
|
61
|
+
@http_proxy = $~[1]
|
62
|
+
end
|
63
|
+
proxy_host, proxy_port = @http_proxy.split(':',2)
|
64
|
+
proxy_port = (proxy_port ? proxy_port.to_i : 80)
|
65
|
+
@http_class = Net::HTTP::Proxy(proxy_host, proxy_port)
|
66
|
+
else
|
67
|
+
@http_class = Net::HTTP
|
68
|
+
end
|
53
69
|
end
|
54
70
|
|
55
71
|
# TODO error check & raise appropriate errors
|
@@ -1191,22 +1207,7 @@ class API
|
|
1191
1207
|
end
|
1192
1208
|
|
1193
1209
|
def new_http
|
1194
|
-
|
1195
|
-
require 'net/https'
|
1196
|
-
require 'time'
|
1197
|
-
|
1198
|
-
if proxy = ENV['HTTP_PROXY']
|
1199
|
-
if proxy =~ /\Ahttp:\/\/(.*)\z/
|
1200
|
-
proxy = $~[1]
|
1201
|
-
end
|
1202
|
-
proxy_host, proxy_port = proxy.split(':',2)
|
1203
|
-
proxy_port = (proxy_port ? proxy_port.to_i : 80)
|
1204
|
-
http_class = Net::HTTP::Proxy(proxy_host, proxy_port)
|
1205
|
-
else
|
1206
|
-
http_class = Net::HTTP
|
1207
|
-
end
|
1208
|
-
|
1209
|
-
http = http_class.new(@host, @port)
|
1210
|
+
http = @http_class.new(@host, @port)
|
1210
1211
|
if @ssl
|
1211
1212
|
http.use_ssl = true
|
1212
1213
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
data/lib/td/client/version.rb
CHANGED