11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cloudrail_si/servicecode/commands/http/RequestCall.rb', line 11
def execute(environment, parameters)
Helper.assert(parameters.length == 2 &&
Helper.is_var_address(parameters[0]) &&
Helper.is_var_address(parameters[1]))
result_var = parameters[0]
options = Helper.resolve(environment, parameters[1])
url = options['url']
method = options['method']
= options['requestHeaders']
request_body = options['requestBody']
Helper.assert(Helper.is_string(url) && Helper.is_string(method))
Helper.assert(.nil? || Helper.is_object())
Helper.assert(request_body.nil? || Helper.is_stream(request_body))
res = Helper.make_request(url, , request_body, method)
response = {}
response['code'] = res.code.to_i
response['message'] = Rack::Utils::HTTP_STATUS_CODES[res.code.to_i],
response['responseHeaders'] = (res.to_hash),
response['responseBody'] = res.body
Helper.log("response:")
Helper.log(response)
Helper.log("\n")
environment.set_variable(result_var, response)
end
|