Skip to content

Commit

Permalink
Removing enforcement of accept header in http_endpoint input (elastic…
Browse files Browse the repository at this point in the history
…#18768) (elastic#18895)

(cherry picked from commit 80130af)

Co-authored-by: Marius Iversen <pillus@chasenet.org>
  • Loading branch information
kvch and P1llus authored Jun 2, 2020
1 parent 7dabaf0 commit 1f44de3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
3 changes: 0 additions & 3 deletions x-pack/filebeat/input/http_endpoint/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ func (in *HttpEndpoint) validateHeader(w http.ResponseWriter, r *http.Request) (
return http.StatusUnsupportedMediaType, in.createErrorMessage("Wrong Content-Type header, expecting application/json")
}

if r.Header.Get("Accept") != "application/json" {
return http.StatusNotAcceptable, in.createErrorMessage("Wrong Accept header, expecting application/json")
}
return 0, ""
}

Expand Down
18 changes: 0 additions & 18 deletions x-pack/filebeat/tests/system/test_http_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,6 @@ def test_http_endpoint_wrong_content_header(self):
assert r.status_code == 415
assert r.text == '{"message": "Wrong Content-Type header, expecting application/json"}'

def test_http_endpoint_wrong_accept_header(self):
"""
Test http_endpoint input with wrong accept header.
"""
self.get_config()
filebeat = self.start_beat()
self.wait_until(lambda: self.log_contains("Starting HTTP server on {}:{}".format(self.host, self.port)))

message = "somerandommessage"
payload = {self.prefix: message}
headers = {"Content-Type": "application/json", "Accept": "application/xml"}
r = requests.post(self.url, headers=headers, data=json.dumps(payload))

filebeat.check_kill_and_wait()

assert r.status_code == 406
assert r.text == '{"message": "Wrong Accept header, expecting application/json"}'

def test_http_endpoint_missing_auth_value(self):
"""
Test http_endpoint input with missing basic auth values.
Expand Down

0 comments on commit 1f44de3

Please sign in to comment.