Join GitHub today
Handle bad HTTP requests #23153
When Netty decodes a bad HTTP request, it marks the decoder result on the HTTP request as a failure, and reroutes the request to GET /bad-request. This either leads to puzzling responses when a bad request is sent to Elasticsearch (if an index named "bad-request" does not exist then it produces an index not found exception and otherwise responds with the index settings for the index named "bad-request"). This commit addresses this by inspecting the decoder result on the HTTP request and dispatching the request to a bad request handler preserving the initial cause of the bad request and providing an error message to the client.