logstash-plugins / logstash-filter-http

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

Cannot send Content-Type header #15

Closed davewat closed 2 years ago

davewat commented 5 years ago

When assigning a header, for example: "Content-Type" => "application/x-www-form-urlencoded", filter sends header, but also sends an additional "content-type: text/plain".

This breaks the API call I am attempting to make, as the end-point complains about the dual headers.

This is because the source provides a binary choice between JSON or text as content type. There are hundred of other possibilities, and this restriction severely limits the ability to make HTTP calls.

An improvement would allow any string as a value for body_format, and can still default to text/plain. Will submit a PR.

ClaudioConsolmagno commented 5 years ago

Facing the same issue, funnily enough when calling elastic apis:

[2019-09-10T18:08:00,312][ERROR][logstash.filters.http    ] error during HTTP request {:url=>"http://localhost:9200/_reindex", :code=>400, 
:response=>"{\"error\":{\"root_cause\":[{\"type\":\"content_type_header_exception\",\"reason\":\"java.lang.IllegalArgumentException: only one Content-Type header should be provided\"}],\"type\":\"content_type_header_exception\",
\"reason\":\"java.lang.IllegalArgumentException: only one Content-Type header should be provided\",\"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"only one Content-Type header should be provided\"}},
\"status\":400}"}

Went back to using the old rest filter (https://github.com/lucashenning/logstash-filter-rest) as it doesn't have this issue.

cc-stjm commented 4 years ago

Would love to see a fix for this - possibly if you supply a content-type header, it overwrites the default

MikeKemmerer commented 3 years ago

Until the body_format config is removed in favor of a pure content-type config, I've submitted a pull request to add a body_format of 'form' to set the content-type header to application/x-www-form-urlencoded. Hopefully it's merged so I don't have to have a custom plugin installed across my fleet of logstash nodes.

clodio commented 3 years ago

+1 to fix this issue

chnry3921 commented 2 years ago

i have the same problem, plugin logstash-filter-http when i maked the docker image so the solution is ?

ClaudioRifo commented 2 years ago

Any news on this, I think I have hit this bug on the latest version.