34
35
36
37
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
70
71
|
# File 'lib/croesus/web_client/web_client.rb', line 34
def self.internal_request(request, timeout)
HTTP_HEADERS.each { |key, value| request.(key, value) }
response = nil
begin
case request.method
when :get
response = RestClient::Request.execute(
method: :get,
url: request.url,
headers: request.,
timeout: timeout
)
when :post
response = RestClient::Request.execute(
method: :post,
url: request.url,
payload: request.body,
headers: request.,
timeout: timeout
)
when :delete
response = RestClient::Request.execute(
method: :delete,
url: request.url,
payload: request.body,
headers: request.,
timeout: timeout
)
end
rescue RestClient::RequestTimeout
raise 'Request Timeout'
rescue RestClient::Exception => e
response = e.response
end
Croesus::WebResponse.new(response)
end
|