Is there a way to force PHP to make a HTTP2 connection to another server just to see if that server supports it?
I've tried:
$options = stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 5,
'protocol_version' => 1.1
)
));
$res = file_get_contents($url, false, $options);
var_dump($http_response_header);
And tried:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
$response = curl_exec($ch);
var_dump($response);
curl_close($ch);
But both ways give me a HTTP1.1 response if I use the following URL https://www.google.com/#q=apache+2.5+http%2F2
I'm sending the request from a HTTP/2 + SSL enabled domain. What am I doing wrong?
As far as I'm aware, cURL is the only transfer method in PHP that supports HTTP 2.0.
You'll first need to test that your version of cURL can support it, and then set the correct version header: