lib/shared/http.rb in yawast-0.7.0.beta2 vs lib/shared/http.rb in yawast-0.7.0.beta3
- old
+ new
@@ -1,10 +1,9 @@
# frozen_string_literal: true
require 'securerandom'
require 'json'
-require 'oj'
module Yawast
module Shared
class Http
def self.setup(proxy, cookie)
@@ -36,19 +35,18 @@
end
end
def self.get_with_code(uri, headers = nil)
body = ''
+ code = nil
begin
req = get_http(uri)
req.use_ssl = uri.scheme == 'https'
res = req.request_get(uri, get_headers(headers))
body = res.read_body
code = res.code
-
- Yawast::Shared::Output.log_json 'debug', 'http_get', uri, Oj.dump(res, Oj.default_options)
rescue # rubocop:disable Style/RescueStandardError, Lint/HandleExceptions
# do nothing for now
end
{body: body, code: code}
@@ -90,11 +88,9 @@
def self.get_status_code(uri)
req = get_http(uri)
req.use_ssl = uri.scheme == 'https'
res = req.head(uri, get_headers)
-
- Yawast::Shared::Output.log_json 'debug', 'http_get_status_code', uri, Oj.dump(res, Oj.default_options)
res.code
end
def self.get_http(uri)