mattbaird/elastigo

gzipped requests omit content-type header

Opened this issue · 0 comments

we are seeing lots of:
[WARN][RestController ] Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.
from elasticsearch.

it is probably a general issue that the header is not added, especially for non-json payloads,

but spefically the code for gzip compression, as introduced here:
https://github.com/mattbaird/elastigo/pull/263/files
omits setting the Content-Type header.
unlike the pre-existing SetBodyJson(), the newly added SetBodyGzip() is missing the logic for setting that header.
a quick solution should be to add the header when generating json, as in SetBodyJson():

	switch v := data.(type) {
	default:
             b, err := json.Marshal(data)
+           r.Header.Set("Content-Type", "application/json")