In someone else's code I came across this option setting for cURL:
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
The PHP documentation says that by default this option is set to CURL_HTTP_VERSION_NONE which lets cURL decide which HTTP version to use. Otherwise, you can force HTTP 1.0 or HTTP 1.1. Someday there will be the option to force HTTP 2.0 (see this thread on the cURL mailing list: http://curl.haxx.se/mail/lib-2013-09/0020.html)
I am still trying to understand the differences between HTTP 1.0 vs 1.1 from the question HTTP 1.0 vs 1.1 and now I'm wondering what kind of considerations are needed for the future with HTTP 2.0.
My questions are:
Is setting the CURLOPT_HTTP_VERSION in an app a good idea if I can't always be sure what HTTP version the server is capable of? Or should I detect the version using $_SERVER['SERVER_PROTOCOL'] and change the CURLOPT_HTTP_VERSION based on that?
If I do know the server is capable of HTTP 1.1 (or someday HTTP 2.0) is there any reason to think cURL won't be able to figure this out?
Is there a case in which it's better to use HTTP 1.0 rather than HTTP 1.1?