升级 zf 2.0.4 => 2.0.6 后出现错误
Zend\Http\Exception\RuntimeException
File:
D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Http\Response.php:449
Message:
Error parsing body - doesn't seem to be a chunked message
Stack trace:
#0 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Http\Response.php(303): Zend\Http\Response->decodeChunkedBody('???????????????...')
#1 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\XmlRpc\Client.php(245): Zend\Http\Response->getBody()
#2 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\XmlRpc\Client.php(318): Zend\XmlRpc\Client->doRequest(Object(Zend\XmlRpc\Request))
#3 D:\xampp\htdocs\htm\base\module\Zone\src\Zone\Controller\AdminController.php(132): Zend\XmlRpc\Client->call('ox.agencyZoneSt...', Array)
#4 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(90): Zone\Controller\AdminController->manageAction()
#5 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#6 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(464): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#7 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#8 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php(107): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#9 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(113): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#10 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#11 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(464): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#12 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 D:\xampp\htdocs\htm\base\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(297): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#14 D:\xampp\htdocs\htm\base\public\index.php(15): Zend\Mvc\Application->run()
#15 {main}
我发现它来自我的Zend\XMLRpc\Client
电话
$httpClient = new \Zend\Http\Client();
$oxClient = new \Zend\XmlRpc\Client('http://xxx.com/www/api/v2/xmlrpc/',$httpClient);
$oxSession = $this->oxClient->call('ox.logon',$oxLogin);
$zone_list = $this->oxClient->call('ox.agencyZoneStatistics',array($oxSession,$agency_id));
我调用 OpenX API 系统。在第一次通话logon
时成功,但第二次失败??!我认为我的问题点decodeChunkedBody
在于Zend\Http\Response.php
. 它无法理解来自 OpenX 的分块响应
protected function decodeChunkedBody($body)
{
$decBody = '';
while (trim($body)) {
if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
throw new Exception\RuntimeException(
"Error parsing body - doesn't seem to be a chunked message"
);
}
$length = hexdec(trim($m[1]));
$cut = strlen($m[0]);
$decBody .= substr($body, $cut, $length);
$body = substr($body, $cut + $length + 2);
}
return $decBody;
}
我卡在这里。第一个旧库(2.0.4)运行良好,我升级它是因为需要使用 zfcuser、zfcbase。但是新的库(2.0.6)在第二次调用(以及任何logon
方法除外)中出现了这个错误。