有沒有辦法強制PHP創建到另一臺服務器的HTTP2連接,以查看該服務器是否支持它?使用PHP發出HTTP/2請求
我已經試過:
$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);
並試圖:
$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);
但這兩種方式給我一個HTTP1.1響應,如果我用下面的URL https://www.google.com/#q=apache+2.5+http%2F2
我從HTTP/2 + SSL啓用域發送請求。我究竟做錯了什麼?
的PHP版本您使用的?看看這裏https://blog.cloudflare.com/tools-for-debugging-testing-and-using-http-2/ –
你有沒有嘗試過:[This Answer](http://stackoverflow.com/questions/) 34606801/how-do-i-send-a-http-2-post-request-in-php) – Hexchaimen
是爲支持HTTP/2而構建的libcurl版本嗎? –