hot-coffee-twitter-ruby 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/twitter.rb +1 -1
- data/lib/twitter/rest_api.rb +19 -9
- metadata +1 -1
data/lib/twitter.rb
CHANGED
data/lib/twitter/rest_api.rb
CHANGED
@@ -17,13 +17,6 @@ module Twitter
|
|
17
17
|
@proxy_user = options[:proxy_user]
|
18
18
|
@proxy_pass = options[:proxy_pass]
|
19
19
|
|
20
|
-
@http = Net::HTTP.new(API_ADDRESS, @port,
|
21
|
-
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
|
22
|
-
@https = Net::HTTP.new(API_ADDRESS, @ssl_port,
|
23
|
-
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
|
24
|
-
@https.use_ssl = true
|
25
|
-
@https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
26
|
-
|
27
20
|
@header = {'User-Agent' => "twitter-ruby/#{Twitter::VERSION}"}
|
28
21
|
@header.merge! options[:header] if options[:header]
|
29
22
|
end
|
@@ -65,9 +58,9 @@ module Twitter
|
|
65
58
|
private
|
66
59
|
def http_request(req, require_auth)
|
67
60
|
if require_auth
|
68
|
-
res =
|
61
|
+
res = https.request(req)
|
69
62
|
else
|
70
|
-
res =
|
63
|
+
res = http.request(req)
|
71
64
|
end
|
72
65
|
data = JSON.parse(res.body)
|
73
66
|
|
@@ -78,5 +71,22 @@ module Twitter
|
|
78
71
|
raise Twitter::ResponseError.new(data['error'], res)
|
79
72
|
end
|
80
73
|
end
|
74
|
+
|
75
|
+
def http
|
76
|
+
Net::HTTP.new(
|
77
|
+
API_ADDRESS, @port,
|
78
|
+
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def https
|
83
|
+
https = Net::HTTP.new(
|
84
|
+
API_ADDRESS, @ssl_port,
|
85
|
+
@proxy_addr, @proxy_port, @proxy_user, @proxy_pass
|
86
|
+
)
|
87
|
+
https.use_ssl = true
|
88
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
89
|
+
https
|
90
|
+
end
|
81
91
|
end
|
82
92
|
end
|