I am using Elastic Search High Level REST API 7.15.0 (Java) and the version of ES deployed on elastic.co is 7.15.2
When making any request using the client, in the logs I can see, the client first makes call to cluster info endpoint (perhaps to do version validation). In this request, the client seems to be passing invalid content type:
Request:
2022-01-26 09:04:44,319 TRACE [I/O dispatcher 1] tracer [RequestLogger.java:83] curl -iX GET 'https://HOST:PORT/'
# HTTP/1.1 200 OK
# Accept-Ranges: bytes
# Cache-Control: private, no-cache, no-store, must-revalidate
# Content-Length: 145060
# Content-Security-Policy: script-src 'unsafe-eval' 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'
# Content-Type: text/html; charset=utf-8
# Date: Wed, 26 Jan 2022 03:19:42 GMT
# Kbn-License-Sig: 289eb19369e758110d5ebea187df9fb14630b5dcc93f827dbe9f72f57a6701eb
# Kbn-Name: 6d4a35ef78c8
# Referrer-Policy: no-referrer-when-downgrade
# Vary: accept-encoding
# X-Cloud-Request-Id: nDBzRS9aRxiH-VMr_cNi_A
# X-Content-Type-Options: nosniff
# X-Found-Handling-Cluster: a62429edfa6148b4918d1911f8287e9e
# X-Found-Handling-Instance: instance-0000000000
Since the Content-Type
for above request is text/html; charset=utf-8
, the server returns HTML response, which the client is not able to parse.
Response:
# <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="viewport" content="width=device-width"/><title>Elastic</title><style>
#
# <more HTMLs>
#
# <h2 class="kbnWelcomeTitle">Please upgrade your browser</h2><div class="kbnWelcomeText">This Elastic installation has strict security requirements enabled that your current browser does not meet.</div></div><script>
# // Since this is an unsafe inline script, this code will not run
# // in browsers that support content security policy(CSP). This is
# // intentional as we check for the existence of __kbnCspNotEnforced__ in
# // bootstrap.
# window.__kbnCspNotEnforced__ = true;
# </script><script src="/bootstrap.js"></script></body></html>
#
This throws the following error:
org.elasticsearch.ElasticsearchException: Failed to parse info response. Check logs for detailed information - Unsupported Content-Type: text/html; charset=utf-8
at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2084)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1732)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1702)
As mentioned in the last line of server's response, does it have something to do with security ? Why would the client make request to the server with invalid content type ?
Here is the response for GET /
from kibana console:
{
"name" : "instance-0000000000",
"cluster_name" : "7ae08a52199c4ff8a7def04f318276a6",
"cluster_uuid" : "24X8eOCzREyoxO9ZpmL7IA",
"version" : {
"number" : "7.15.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "93d5a7f6192e8a1a12e154a2b81bf6fa7309da0c",
"build_date" : "2021-11-04T14:04:42.515624022Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Any help on this ?