Closed trungpham closed 12 years ago
def execute(req) res = Net::HTTP.new(@uri.host).start { |http| http.request(req) } if res.is_a? Net::HTTPSuccess if res.body.nil? or res.body.empty? return res.code, nil else begin return res.code, JSON.parse(res.body) rescue raise "Invalid JSON response: #{res.body}" end end elsif res.is_a? Net::HTTPUnauthorized raise SecurityError, "Authorization required" elsif res.is_a? Net::HTTPBadRequest raise ArgumentError, res.body else raise HttpCodeException.new(res.code, res.body) end end
it seems like the code only forward the host part of the uri, and not the port.
def execute(req) res = Net::HTTP.new(@uri.host).start { |http| http.request(req) } if res.is_a? Net::HTTPSuccess if res.body.nil? or res.body.empty? return res.code, nil else begin return res.code, JSON.parse(res.body) rescue raise "Invalid JSON response: #{res.body}" end end elsif res.is_a? Net::HTTPUnauthorized raise SecurityError, "Authorization required" elsif res.is_a? Net::HTTPBadRequest raise ArgumentError, res.body else raise HttpCodeException.new(res.code, res.body) end end
it seems like the code only forward the host part of the uri, and not the port.