lib/shared/http.rb in yawast-0.6.0.beta4 vs lib/shared/http.rb in yawast-0.6.0.beta5
- old
+ new
@@ -1,6 +1,7 @@
require 'securerandom'
+require 'json'
module Yawast
module Shared
class Http
def self.setup(proxy, cookie)
@@ -43,9 +44,24 @@
rescue
#do nothing for now
end
body
+ end
+
+ def self.get_json(uri)
+ body = ''
+
+ begin
+ req = get_http(uri)
+ req.use_ssl = uri.scheme == 'https'
+ res = req.request_get(uri, { 'User-Agent' => "YAWAST/#{Yawast::VERSION}" })
+ body = res.read_body
+ rescue
+ #do nothing for now
+ end
+
+ JSON.parse body
end
def self.put(uri, body, headers = nil)
begin
req = get_http(uri)