Skip to content

Commit

Permalink
adding possibility to override content-type checks, it was breaking c…
Browse files Browse the repository at this point in the history
…ertain webhooks that is not able to set content-headers at all. Still defaults to application/json (#20232) (#20237)

(cherry picked from commit 98a423d)

Co-authored-by: Marius Iversen <pillus@chasenet.org>
  • Loading branch information
marc-gr and P1llus authored Jul 27, 2020
1 parent 42f099a commit 9f2cd03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions x-pack/filebeat/docs/inputs/input-http-endpoint.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Custom response example:
prefix: "json"
----

Disable Content-Type checks
["source","yaml",subs="attributes"]
----
{beatname_lc}.inputs:
- type: http_endpoint
enabled: true
listen_address: 192.168.1.1
content_type: ""
prefix: "json"
----

Basic auth and SSL example:
["source","yaml",subs="attributes"]
----
Expand Down Expand Up @@ -80,6 +91,12 @@ If `basic_auth` is enabled, this is the username used for authentication against

If `basic_auth` is eanbled, this is the password used for authentication against the HTTP listener. Requires `username` to also be set.

[float]
==== `content_type`

By default the input expects the incoming POST to include a Content-Type of `application/json` to try to enforce the incoming data to be valid JSON.
In certain scenarios when the source of the request is not able to do that, it can be overwritten with another value or set to null

[float]
==== `response_code`

Expand Down
2 changes: 2 additions & 0 deletions x-pack/filebeat/input/http_endpoint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type config struct {
ListenPort string `config:"listen_port"`
URL string `config:"url"`
Prefix string `config:"prefix"`
ContentType string `config:"content_type"`
}

func defaultConfig() config {
Expand All @@ -36,6 +37,7 @@ func defaultConfig() config {
ListenPort: "8000",
URL: "/",
Prefix: "json",
ContentType: "application/json",
}
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/http_endpoint/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (e *httpEndpoint) Run(ctx v2.Context, publisher stateless.Publisher) error
username: e.config.Username,
password: e.config.Password,
method: http.MethodPost,
contentType: "application/json",
contentType: e.config.ContentType,
}

handler := &httpHandler{
Expand Down

0 comments on commit 9f2cd03

Please sign in to comment.