huginn_http_request_agent 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/huginn_http_request_agent/http_request_agent.rb +54 -20
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: efc2ffa3f090b8c268492b91a79a0914ee18bbbdd431b714160d65856f34be24
|
4
|
+
data.tar.gz: 276b80b72c60689cedb18d2f1e6e9fed117bbfe97229d06aa138e04a3cca8c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64f2207730c600ce39d38267057377af946164c50dbf15fe6b0a9108384fb16685511cef5105bffbee462ed59c493f60b78dd5bd2969061318be0cfd0eac169e
|
7
|
+
data.tar.gz: c2204699225a8867b3a4b5955724935e49964b6d1e65158413c8af42035a9dd4506c0e090977a96c216784b2fd93855e94b186967344aa4e2860d2e23e251ba5
|
@@ -242,34 +242,68 @@ module Agents
|
|
242
242
|
log({ method: method, url: url, body: body, headers: headers })
|
243
243
|
end
|
244
244
|
|
245
|
-
|
245
|
+
output_event = interpolated['output_mode'].to_s == 'merge' ? event.payload.dup : {}
|
246
246
|
|
247
|
-
|
248
|
-
if interpolated['timeout'].to_i
|
249
|
-
request.options.timeout = interpolated['timeout'].to_i
|
250
|
-
end
|
247
|
+
begin
|
251
248
|
|
252
|
-
|
253
|
-
if interpolated['open_timeout'].to_i
|
254
|
-
request.options.open_timeout = interpolated['open_timeout'].to_i
|
255
|
-
end
|
249
|
+
response = faraday.run_request(method.to_sym, url, body, headers) { |request|
|
256
250
|
|
257
|
-
|
258
|
-
|
251
|
+
# open/read timeout in seconds
|
252
|
+
if interpolated['timeout'].to_i
|
253
|
+
request.options.timeout = interpolated['timeout'].to_i
|
254
|
+
end
|
259
255
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
256
|
+
# connection open timeout in seconds
|
257
|
+
if interpolated['open_timeout'].to_i
|
258
|
+
request.options.open_timeout = interpolated['open_timeout'].to_i
|
259
|
+
end
|
260
|
+
|
261
|
+
request.params.update(params) if params
|
262
|
+
}
|
263
|
+
|
264
|
+
if boolify(interpolated['emit_events'])
|
265
|
+
create_event payload: output_event.merge(
|
266
|
+
body: response.body,
|
267
|
+
status: response.status
|
268
|
+
).merge(
|
269
|
+
event_headers_payload(response.headers)
|
270
|
+
)
|
271
|
+
end
|
272
|
+
rescue => e
|
273
|
+
handle_req_error(e, output_event, url)
|
268
274
|
end
|
269
275
|
end
|
270
276
|
|
271
277
|
def event_headers_key
|
272
278
|
super || 'headers'
|
273
279
|
end
|
274
|
-
|
280
|
+
|
281
|
+
def handle_req_error( error, output_payload, endpoint )
|
282
|
+
|
283
|
+
error_status = defined?(error.response_status) && !error.response_status.nil? ? error.response_status : 500
|
284
|
+
|
285
|
+
# NOTE: `options['payload']`` below is intentionally _NOT_ interpolated.
|
286
|
+
# The primary reason for this is that it may contain sensitive values
|
287
|
+
# By passing the raw option, we will see liquid placeholders instead.
|
288
|
+
# This wiill assist with debugging while also not exposing secrets.
|
289
|
+
|
290
|
+
log({
|
291
|
+
error_message: error.message,
|
292
|
+
status_code: error_status,
|
293
|
+
endpoint: endpoint,
|
294
|
+
payload_options: options['payload'],
|
295
|
+
})
|
296
|
+
|
297
|
+
if boolify(interpolated['emit_events'])
|
298
|
+
create_event payload: output_payload.merge(
|
299
|
+
status: error_status,
|
300
|
+
error_message: error.message,
|
301
|
+
endpoint: endpoint,
|
302
|
+
payload_options: options['payload'],
|
303
|
+
)
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
end # <-- End of class
|
275
309
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_http_request_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Spizziri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
87
|
-
rubygems_version: 2.6.10
|
86
|
+
rubygems_version: 3.0.3
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: The Http Request Agent is intended to be an abstract agent that allows for
|