HTTP input plugin customize response-header

Hello! I'm working with logstash and the http input plugin. I've a datasource that send a data stream to logstash and require as response header content-type => application/json. I'm using the following configuration, but the response content-type is always text/plain as shown below:

     input {
      http {
        port => 8080
        codec => "json"
        response_headers => {
          "Access-Control-Allow-Origin" => "*"
          "Content-Type" => "application/json"
          "Access-Control-Allow-Headers" => "Origin, X-Requested-With, Content-Type, Accept"
    output {
      stdout {}

Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< content-type: text/plain
< content-length: 2
< access-control-allow-origin: *
< access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept

Any suggestion?

Looking at the code, it adds the response_headers to the response, and then, unless it is returning a 204, it forces the content-type to text/plain. I believe netty stores the headers as a hash, so this would override the application/json. You can verify that this is the case by making a call to the input (with curl) and provide no content. I would expect that you will then get application/json.

I cannot think of a workaround less heavyweight than configuring a web proxy in front of logstash to edit the response.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.