mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Make sure status
is an integer when set
This commit is contained in:
parent
a94cd7fd6d
commit
9074f3115e
2 changed files with 5 additions and 5 deletions
|
@ -134,7 +134,7 @@ module Agents
|
|||
|
||||
* `_response_`: A response object with the following keys:
|
||||
|
||||
* `status`: HTTP status as integer. (Almost always 200) When parsing `data_from_event`, this is set to the value of the `status` key in the incoming Event.
|
||||
* `status`: HTTP status as integer. (Almost always 200) When parsing `data_from_event`, this is set to the value of the `status` key in the incoming Event, if it is a number or a string convertible to an integer.
|
||||
|
||||
* `headers`: Response headers; for example, `{{ _response_.headers.Content-Type }}` expands to the value of the Content-Type header. Keys are insensitive to cases and -/_. When parsing `data_from_event`, this is constructed from the value of the `headers` key in the incoming Event.
|
||||
|
||||
|
@ -694,7 +694,7 @@ module Agents
|
|||
|
||||
# Integer value of HTTP status
|
||||
def status
|
||||
@object.payload[:status]
|
||||
Integer(@object.payload[:status]) rescue nil
|
||||
end
|
||||
|
||||
# The URL
|
||||
|
|
|
@ -1198,7 +1198,7 @@ fire: hot
|
|||
'value' => '{{ value }}',
|
||||
'url' => '{{ url | to_uri: _response_.url }}',
|
||||
'type' => '{{ _response_.headers.content_type }}',
|
||||
'status' => '{{ _response_.status }}'
|
||||
'status' => '{{ _response_.status | as_object }}'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
@ -1207,7 +1207,7 @@ fire: hot
|
|||
expect {
|
||||
@checker.receive([@event])
|
||||
}.to change { Event.count }.by(1)
|
||||
expect(@checker.events.last.payload).to eq({ 'value' => 'world', 'url' => 'http://example.com/world', 'type' => 'application/json', 'status' => '200' })
|
||||
expect(@checker.events.last.payload).to eq({ 'value' => 'world', 'url' => 'http://example.com/world', 'type' => 'application/json', 'status' => 200 })
|
||||
end
|
||||
|
||||
it "should support merge mode" do
|
||||
|
@ -1216,7 +1216,7 @@ fire: hot
|
|||
expect {
|
||||
@checker.receive([@event])
|
||||
}.to change { Event.count }.by(1)
|
||||
expect(@checker.events.last.payload).to eq(@event.payload.merge('value' => 'world', 'url' => 'http://example.com/world', 'type' => 'application/json', 'status' => '200'))
|
||||
expect(@checker.events.last.payload).to eq(@event.payload.merge('value' => 'world', 'url' => 'http://example.com/world', 'type' => 'application/json', 'status' => 200))
|
||||
end
|
||||
|
||||
it "should output an error when nothing can be found at the path" do
|
||||
|
|
Loading…
Add table
Reference in a new issue