Maison >développement back-end >tutoriel php >PHP curl报错“Problem (二) in the Chunked-Encoded data”解决方案

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBoriginal
2016-06-13 12:14:001254parcourir

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>

即可修复该问题。

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn