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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…