38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/spaceborne.rb', line 38
def make_request(method, url, options = {})
@json_body = nil
@request_body = nil
if options[:headers] && options[:headers].has_key?(:use_proxy)
proxy_option = options[:headers][:use_proxy]
RestClient.proxy = proxy_option
end
= .merge(options[:headers] || {})
res = if method == :post || method == :patch || method == :put
begin
@request_body = options[:body].nil? ? '' : options[:body]
if options[:body].is_a?(Hash)
if .delete(:nonjson_data)
.delete('Content-Type')
else
.merge!(no_restclient_headers: true)
@request_body = @request_body.to_json
end
end
RestClient.send(method, get_url(url), @request_body, )
rescue RestClient::Exception => e
e.response
end
else
begin
RestClient.send(method, get_url(url), )
rescue RestClient::Exception => e
e.response
end
end
res
end
|