PHP 中的 CURL 是否支持 SPDY


Does CURL in PHP support SPDY?

我在PHP中使用cURL连接到我知道使用Google新协议SPDY的不同API。

但我不确定默认情况下PHP cURL是否支持SPDY。如果没有,有没有办法配置它以支持 SPDY?

在我的

系统上使用 PHP 5.5.19 和 curl 7.39.0 ,答案是否定的。你可以检查你的curl支持什么,通过启用"自动"编码,让curl列出所有支持的编码到服务器(通过CURLOPT_ENCODING->空字符串启用自动),然后检查curl发送的标头,如下所示:

<?php
    if(array_key_exists("curlcall",$_GET)){
    if(is_callable("http_get_request_headers")){
    var_dump(http_get_request_headers());       
    }elseif(is_callable("apache_request_headers")){
        var_dump(apache_request_headers());
    } else {
        throw new Exception("unsupported enviroment (both http_get_request_headers and apache_request_headers missing!)");
    }
    } else {
    $ch=curl_init("http://127.0.0.1/a.php?curlcall");
    curl_setopt($ch,CURLOPT_ENCODING,"");
    curl_exec($ch);
    }

在我的系统上,我得到以下输出:

array(3) { ["Host"]=> string(9) "127.0.0.1" ["Accept"]=> string(3) "*/*" 
["Accept-Encoding"]=> string(13) "deflate, gzip" }

这意味着支持放气和 gzip(以及默认值 - 没有编码/纯文本)(还没有 SPDY 支持 im afriad)