# HTTP input plugin customize response-header

**URL:** https://discuss.elastic.co/t/http-input-plugin-customize-response-header/265547
**Category:** Logstash
**Created:** [February 25, 2021, 9:21pm UTC](https://discuss.elastic.co/t/http-input-plugin-customize-response-header/265547 "2021-02-25T21:21:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stemons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stemons/32/84571_2.png) [@stemons](https://discuss.elastic.co/u/stemons)
#### Post date: [February 25, 2021, 9:21pm UTC](https://discuss.elastic.co/t/http-input-plugin-customize-response-header/265547/1 "2021-02-25T21:21:26Z")

</div>

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:

```auto
     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?  
Thanks

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [February 25, 2021, 9:54pm UTC](https://discuss.elastic.co/t/http-input-plugin-customize-response-header/265547/2 "2021-02-25T21:54:02Z")

</div>

> [@stemons](#):
>
> Any suggestion?

Looking at the code, [it adds](https://netty.handler.codec.DefaultTextHeaders) 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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 25, 2021, 9:54pm UTC](https://discuss.elastic.co/t/http-input-plugin-customize-response-header/265547/3 "2021-03-25T21:54:30Z")

</div>

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