Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filebeat Input][HTTP_endpoint] Add possibility to override content-type header #20232

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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