踩坑记录(1).[php]fopen使用HTTP/1.1协议

[php]fopen使用HTTP/1.1协议

php版本:5.6.40
注:在没有配置protocol_version的情况下,protocol_version默认值为1.0.
fopen使用1.1协议写法:

<?php
$stream = stream_context_create([
    "http" => [
        "protocol_version" => 1.1 //使用1.1协议
    ]
]);
$f = fopen("http://mydomain.com", "r", false, $stream);
fclose($f);

yii2 使用1.1协议写法:

$client = new \yii\httpclient\Client();
$client->transport = 'yii\httpclient\CurlTransport';
$response = $client->createRequest()
    ->setMethod('GET')
    ->setUrl('mydomain.com')
    ->setOptions([
	        "protocol_version" => 1.1 //使用1.1协议
    ])
    ->send();

php-src 5.6.40部分源码:
php-src/ext/standard/http_fopen_wrapper.c

/* protocol version we are speaking */
	if (context && (tmpzval = php_stream_context_get_option(context, "http", "protocol_version")) != NULL) {
		char *protocol_version;
		spprintf(&protocol_version, 0, "%.1F", zval_get_double(tmpzval));

		smart_str_appends(&req_buf, " HTTP/");
		smart_str_appends(&req_buf, protocol_version);
		smart_str_appends(&req_buf, "\r\n");
		efree(protocol_version);
	} else {
		smart_str_appends(&req_buf, " HTTP/1.0\r\n");
	}

PHP官网仓库地址(github)
php manual手册

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:根据您提供的信息,您在使用openssl自做CA自签发SSL证书时遇到了一个错误。错误提示是无法打开配置文件openssl.cnf,报错信息为No such file or directory。解决方法可以参考提供的文章\[1\]。引用\[2\]:另外,您还提到了一个例子,其中涉及到了安全提供者的配置。引用\[3\]:您还提到了添加jar包和修改security配置的方法。根据您提供的问题描述,您遇到了一个编译错误,缺少二进制运算符。根据提供的信息,无法确定具体的原因。请检查您的代码和依赖项,确保正确引入了所需的头文件和库文件,并正确使用二进制运算符。如果问题仍然存在,请提供更多的上下文信息,以便我们能够更好地帮助您解决问题。 #### 引用[.reference_title] - *1* [9748:error:02001002:system library:fopen:No such file or directory:.\\crypto\\bio\\bss_file.c:168:fopen](https://blog.csdn.net/swanabin/article/details/48441121)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [SM4加密报错No such algorithm: SM4/ECB/PKCS5Padding](https://blog.csdn.net/qq_44646316/article/details/128368752)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值