PHP是否支持使用HTTP / 2协议创建流上下文?

时间:2018-08-01 17:24:17

标签: php http2

在当前的PHP文档或其他地方,创建流上下文时我找不到有关HTTP协议版本2的任何信息。

用法是否透明,还是必须考虑HTTP / 2的特殊功能?在流上下文中使用HTTP / 2有意义吗?

我知道CURL会为我处理所有这一切-但我不想使用CURL。

这是FOPEN的一个小例子:

$context = [
    "http" => [
        "header" => [
            "Accept-encoding: gzip, deflate",
            "Connection: close",
            "Upgrade-insecure-requests: 1",
            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Dnt: 1",
            "Accept-language: en-us",
            "Content-type: text/html"
        ],
        "ignore_errors" => true,
        "max_recirects" => 3,
        "method" => "POST",
        "protocol_version" => 2.0,
        "timeout" => 30.0,
        "content" => ""
    ],
    "ssl" => [
        "disable_compression" => false,
        "verify_peer" => true,
        "verify_depth" => 5,
        "SNI_enabled" => true
    ]
];

$stream = stream_context_create($context);
$result = fopen(base64_decode(self::URL), "rb", false, $stream);

0 个答案:

没有答案