I'm seeing a lot of these warnings in our logs
[2017-06-21T09:36:18,650][WARN ][org.elasticsearch.deprecation.rest.RestController] Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.
We're running Elastic version 5.3.2 in the cloud, with elasticsearch-php version 5.2.0
This issue is created as a request from @polyfractal here:
https://discuss.elastic.co/t/warn-content-type-detection-for-rest-requests-is-deprecated/90269
Can you show your code that creates the client, and perhaps the section of code that is sending the requests which trigger this warning?
Ofcourse, but it's nothing fancy, just create the client with one host:
Elasticsearch\ClientBuilder::create()->setHosts( [ $sUrl ] )->build();
Ok, I'll dig into this to see if I can recreate locally. Do you happen to know which endpoints are throwing this? All endpoints? Just search?
No idea which endpoints are throwing this, I don't see the warning in my own scripts. They only appear in the cluster logs in the elastic cloud.
Hi
we are seeing the same issues here in an environment with all packages involved updated up to 5.4.X where we have beaver + redis + logstash + elasticsearch as workflow. And we are getting same logs.
Just to help to detect the issue guys.
Regards,
R
Roger, thanks. I must have something incorrect with the header syntax, or a regression of some sort. This is on my todo list for today, will update as I find out more :)
Hmm, well I think it's going to take some more sleuthing. I can recreate this locally if I remove the content-type headers manually (https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/ClientBuilder.php#L476-L490). Otherwise, the server doesn't complain about missing headers.
This was tagged in ES-PHP 5.1.2. Can you confirm you're on that version or greater?
I'll spin up a cloud instance to see if there is something going on there.
Is it possible there is something else that is accessing the cluster? Like an old version of Kibana, or a script manually curl'ing, nagios setup, etc that might not be sending the right headers?
There is one script that's running each day at 1:05 (with our timezone that would be 23:05 in the logs), that does shell_exec( 'curl -s ' . $url . '/_aliases' ), but this is not giving that warning.
Actually the last time the warning occured was june 28th at 13:13.
And yes, I can confirm that we are on ES-PHP 5.2.0
And about 50 minutes after that comment they were back ;')
@polyfractal Are you sure that it should be 'Content-type'? Seems to me it must be 'Content-Type'.
https://tools.ietf.org/html/rfc7231#section-3.1.1.5
I think this is another instance of https://github.com/elastic/elasticsearch-php/issues/614, e.g. headers are technically case-insensitive, but some servers/proxies may not be quite up-to-spec and looking for specific case.
Similar to the host header, since it theoretically doesn't matter, I'll make the change to upper-case these as a path of least friction. Dunno if that's the problem here but cant hurt! Thanks for the tip @arconen :)
@polyfractal Welcome ;)
Changed here: b8ad96cec1d7cdf877e9448bd155d84010d9e82b
can you merge this also to version 5.3?
Guys, pls cherry pick this to 5.3.x version, because elasticsearch 5.6.14 also spam to logs about
Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.
Solved by @polyfractal with commit https://github.com/elastic/elasticsearch-php/commit/b8ad96cec1d7cdf877e9448bd155d84010d9e82b
Most helpful comment
can you merge this also to version 5.3?