Rumah >pembangunan bahagian belakang >tutorial php >PHP curl报错“Problem (二) in the Chunked-Encoded data”解决方案

PHP curl报错“Problem (二) in the Chunked-Encoded data”解决方案

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBasal
2016-06-13 12:14:001229semak imbas

PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace; padding:0px; margin:0px; word-break:normal; border:0px; display:inline; line-height:inherit; word-wrap:normal; background:transparent">作者:zhanhailiang 日期:2015-01-23</code>

本地环境:

<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace; padding:0px; margin:0px; word-break:normal; border:0px; display:inline; line-height:inherit; word-wrap:normal; background:transparent">系统版本:Microsoft Windows 6.1.7601PHP版本:PHP 5.3.29php_curl.dll扩展版本:7.35.0</code>

Windows环境下遇到一个很奇怪的问题,使用PHP curl发送请求报错:

<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace; padding:0px; margin:0px; word-break:normal; border:0px; display:inline; line-height:inherit; word-wrap:normal; background:transparent">错误码:56错误信息:Problem (2) in the Chunked-Encoded data</code>

但是使用浏览器直接访问又正常,怀疑是php_curl.dll扩展本身的bug,解决方案如下:

在PHP curl头部添加HTTP版本信息即可解决:

<code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace; padding:0px; margin:0px; word-break:normal; border:0px; display:inline; line-height:inherit; word-wrap:normal; background:transparent">curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);</code>

即可修复该问题。

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:PHP的一些案例研究(2)Artikel seterusnya:$array[零]与$array['0']的区别