logstash-input-http_poller 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe8e760b955fa42eefe9e32efb1d22a45a5df599
4
- data.tar.gz: 78892043c7636c6ae2390f0a0434049f2c0746a7
3
+ metadata.gz: a3c874545f73eaab85519980784f809bff6d9d38
4
+ data.tar.gz: 6d10b710df16a97a37f8296ad813afa6d2a95238
5
5
  SHA512:
6
- metadata.gz: 981963c7a77ca4ee065efea7dce6cfcef8764e58cca1c168275da196bf9f8255ec34af2ad52fc9051d019faf7820628fb41c37744ee492107f46e9f20f818ae8
7
- data.tar.gz: f1db89d4d1a1a44dd750c0348e95b95875844af1a815efb4f9f8bb8e56084d45aa119cd433fb83f0ab775df8e54313783dac51d0997d7c8a6ec1a6f544362fb4
6
+ metadata.gz: d054bd270a593d98a49ac1b16accf096d45319f612c2bfa60ba4d0ff1cbe21d7b800979e87265d509259343db18a76ce66279b24408225c4cf2b1cb1e4243a33
7
+ data.tar.gz: ae93340bfbd16af78c59de5da8d5f181ab6bbff077ca31daf6dc2f4144e59df1cfb779ee0c35ec596b50e2a7137ab20bd84d012a188bf7abbe0b5ff82402e7b1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## 3.1.1
2
+ - Handle empty bodies correctly
1
3
  ## 3.1.0
2
4
  - Use rufus-scheduler for more flexible scheduling. Many thanks to [@hummingV](https://github.com/hummingV) for this contribution. ([#58](https://github.com/logstash-plugins/logstash-input-http_poller/pull/58))
3
5
 
@@ -240,8 +240,16 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
240
240
 
241
241
  private
242
242
  def handle_success(queue, name, request, response, execution_time)
243
- @codec.decode(response.body) do |decoded|
244
- event = @target ? LogStash::Event.new(@target => decoded.to_hash) : decoded
243
+ body = response.body
244
+ # If there is a usable response. HEAD requests are `nil` and empty get
245
+ # responses come up as "" which will cause the codec to not yield anything
246
+ if body && body.size > 0
247
+ @codec.decode(body) do |decoded|
248
+ event = @target ? LogStash::Event.new(@target => decoded.to_hash) : decoded
249
+ handle_decoded_event(queue, name, request, response, event, execution_time)
250
+ end
251
+ else
252
+ event = ::LogStash::Event.new
245
253
  handle_decoded_event(queue, name, request, response, event, execution_time)
246
254
  end
247
255
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-http_poller'
3
- s.version = '3.1.0'
3
+ s.version = '3.1.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Poll HTTP endpoints with Logstash."
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -398,6 +398,7 @@ describe LogStash::Inputs::HTTP_Poller do
398
398
 
399
399
  describe "a valid request and decoded response" do
400
400
  let(:payload) { {"a" => 2, "hello" => ["a", "b", "c"]} }
401
+ let(:response_body) { LogStash::Json.dump(payload) }
401
402
  let(:opts) { default_opts }
402
403
  let(:instance) {
403
404
  klass.new(opts)
@@ -414,7 +415,7 @@ describe LogStash::Inputs::HTTP_Poller do
414
415
  instance.register
415
416
  u = url.is_a?(Hash) ? url["url"] : url # handle both complex specs and simple string URLs
416
417
  instance.client.stub(u,
417
- :body => LogStash::Json.dump(payload),
418
+ :body => response_body,
418
419
  :code => code
419
420
  )
420
421
  allow(instance).to receive(:decorate)
@@ -430,6 +431,14 @@ describe LogStash::Inputs::HTTP_Poller do
430
431
  end
431
432
 
432
433
  include_examples("matching metadata")
434
+
435
+ context "with an empty body" do
436
+ let(:response_body) { "" }
437
+ it "should return an empty event" do
438
+ instance.send(:run_once, queue)
439
+ expect(event.get("[_http_poller_metadata][response_headers][content-length]")).to eql("0")
440
+ end
441
+ end
433
442
 
434
443
  context "with metadata omitted" do
435
444
  let(:opts) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http_poller
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-14 00:00:00.000000000 Z
12
+ date: 2017-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement