lib/logstash/inputs/http_poller.rb in logstash-input-http_poller-4.0.5 vs lib/logstash/inputs/http_poller.rb in logstash-input-http_poller-5.0.0
- old
+ new
@@ -15,12 +15,10 @@
# A Hash of urls in this format : `"name" => "url"`.
# The name and the url will be passed in the outputed event
config :urls, :validate => :hash, :required => true
- config :interval, :validate => :number, :obsolete => "The interval options is obsolete. Use schedule instead"
-
# Schedule of when to periodically poll from the urls
# Format: A hash with
# + key: "cron" | "every" | "in" | "at"
# + value: string
# Examples:
@@ -163,17 +161,23 @@
def handle_success(queue, name, request, response, execution_time)
body = response.body
# If there is a usable response. HEAD requests are `nil` and empty get
# responses come up as "" which will cause the codec to not yield anything
if body && body.size > 0
- @codec.decode(body) do |decoded|
+ decode_and_flush(@codec, body) do |decoded|
event = @target ? LogStash::Event.new(@target => decoded.to_hash) : decoded
handle_decoded_event(queue, name, request, response, event, execution_time)
end
else
event = ::LogStash::Event.new
handle_decoded_event(queue, name, request, response, event, execution_time)
end
+ end
+
+ private
+ def decode_and_flush(codec, body, &yielder)
+ codec.decode(body, &yielder)
+ codec.flush(&yielder)
end
private
def handle_decoded_event(queue, name, request, response, event, execution_time)
apply_metadata(event, name, request, response, execution_time)