Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 864c8ba

Browse files
authored
Change Content-Type header to be Kibana 7 compatible (#983)
Closes: #994
1 parent 740da42 commit 864c8ba

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

quesma/quesma/http_headers.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package quesma
44

55
import (
66
"net/http"
7-
"quesma/logger"
87
"slices"
98
)
109

@@ -36,18 +35,18 @@ func addProductAndContentHeaders(request http.Header, response http.Header) {
3635
response.Set(contentTypeHeaderKey, "application/json; charset=UTF-8")
3736
} else {
3837
response.Set(elasticSearchResponseHeaderKey, elasticSearchResponseHeaderValue)
39-
response.Set(contentTypeHeaderKey, "application/vnd.elasticsearch+json;compatible-with=8")
38+
//response.Set(contentTypeHeaderKey, "application/vnd.elasticsearch+json;compatible-with=8")
4039
}
40+
// WARNING:
41+
// Elasticsearch 8.x responds with `Content-Type: application/vnd.elasticsearch+json;compatible-with=8`
42+
// Elasticsearch 7.x responds with `Content-Type: application/json; charset=UTF-8`
43+
// We decided to always use the 7.x response for now, but we might need to change it in the future.
44+
// Specifically, we might need to change this behaviour by introducing Elasticsearch 8 and Elasticsearch 7-specific frontend connectors.
45+
// More in: https://github.com/QuesmaOrg/quesma/issues/994
46+
response.Set(contentTypeHeaderKey, "application/json; charset=UTF-8")
4147
response.Set(opaqueIdHeaderKey, "unknownId")
4248
}
4349

44-
func LogMissingEsHeaders(elasticsearchHeaders, quesmaHeaders http.Header, reqId string) {
45-
missingHeaders := findMissingElasticsearchHeaders(elasticsearchHeaders, quesmaHeaders)
46-
for _, headerName := range missingHeaders {
47-
logger.Warn().Str(logger.RID, reqId).Msgf("Header %s is missing in Quesma's response", headerName)
48-
}
49-
}
50-
5150
func findMissingElasticsearchHeaders(elasticsearchHeaders, quesmaHeaders http.Header) []string {
5251
var missingHeaders []string
5352
for esHeaderName := range elasticsearchHeaders {

quesma/quesma/http_headers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Test_EsHeaders(t *testing.T) {
2525
response = make(http.Header)
2626
addProductAndContentHeaders(request, response)
2727
assert.Equal(t, elasticSearchResponseHeaderValue, response.Get(elasticSearchResponseHeaderKey), "X-Elastic-Product set correctly")
28-
assert.Equalf(t, "application/vnd.elasticsearch+json;compatible-with=8", response.Get(contentTypeHeaderKey), "Content-Type set correctly")
28+
assert.Equalf(t, "application/json; charset=UTF-8", response.Get(contentTypeHeaderKey), "Content-Type set correctly")
2929
}
3030

3131
func TestFindMissingElasticsearchHeaders(t *testing.T) {

0 commit comments

Comments
 (0)