logstash-plugins / logstash-filter-http

HTTP Filter Plugin for Logstash
Apache License 2.0
12 stars 29 forks source link

Plugin crashes when it receives Array type of content-type header. #45

Closed mashhurs closed 1 year ago

mashhurs commented 1 year ago

Logstash information:

Please include the following information:

  1. Logstash version (e.g. bin/logstash --version)
  2. Logstash installation source (e.g. built from source, with a package manager: DEB/RPM, expanded from tar or zip archive, docker)
  3. How is Logstash being run (e.g. as a service/service manager: systemd, upstart, etc. Via command line, docker/kubernetes)
  4. How was the Logstash Plugin installed

JVM (e.g. java -version):

If the affected version of Logstash is 7.9 (or earlier), or if it is NOT using the bundled JDK or using the 'no-jdk' version in 7.10 (or higher), please provide the following information:

  1. JVM version (java -version)
  2. JVM installation source (e.g. from the Operating System's package manager, from source, etc).
  3. Value of the JAVA_HOME environment variable if set.

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:

Steps to reproduce:

http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': ['text/plain', 'logstash/custom-type']} ); response.end('Hello World\n'); }).listen(8081);

console.log('Server running at http://127.0.0.1:8081/');

- Config Logstash with `filter-http` which calls and receives list of content-type headers

filter { http { url => "http://localhost:8081" target_body => "body" target_headers => "headers" } }

- Run Logstash and observe the error

**Provide logs (if relevant)**:

[2023-03-15T11:36:25,372][ERROR][logstash.javapipeline ][main] Pipeline worker error, the pipeline will be stopped {:pipeline_id=>"main", :error=>"(NoMethodError) undefined method `split' for [\"text/plain\", \"logstash/custom-type\"]:Array", :exception=>Java::OrgJrubyExceptions::NoMethodError, :backtrace=> ["RUBY.process_response(/Users/mashhur/Dev/elastic/logstash/logstash-plugins/logstash-filter- http/lib/logstash/filters/http.rb:136)", "RUBY.filter(/Users/mashhur/Dev/elastic/logstash/logstash-plugins/logstash-filter- http/lib/logstash/filters/http.rb:96)", "RUBY.do_filter(/Users/mashhur/Dev/elastic/logstash/logstash- core/lib/logstash/filters/base.rb:159)", "RUBY.multi_filter(/Users/mashhur/Dev/elastic/logstash/logstash- core/lib/logstash/filters/base.rb:178)", "org.jruby.RubyArray.each(org/jruby/RubyArray.java:1865)", "RUBY.multi_filter(/Users/mashhur/Dev/elastic/logstash/logstash-core/lib/logstash/filters/base.rb:175)", "org.logstash.config.ir.compiler.AbstractFilterDelegatorExt.multi_filter(org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.ja va:133)", "RUBY.start_workers(/Users/mashhur/Dev/elastic/logstash/logstash-core/lib/logstash/java_pipeline.rb:304)"], :thread=>"#<Thread:0x7fc1e9a8@/Users/mashhur/Dev/elastic/logstash/logstash-core/lib/logstash/java_pipeline.rb:134 sleep>"}