0
我想通過cURL從zend framework 2控制檯路由中發佈表單。ZF2 - 發佈到遠程URL時的Cookie異常頭
我做這樣的事情
php public/index.php myroute
要呼叫終端的路徑。這條路線裏面是以下幾點:
$request = new \Zend\Http\Request;
$request->setMethod('POST');
$request->setUri('http://somesite.com');
$request->getHeaders()->addHeaders([
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'
]);
/* set post fields */
$aData = array('hello' => 'world');
$request->setContent($request->getPost()->toString());
/* just to look at request string in console */
echo $request->toString()."\n";
/* post the data */
$client = new \Zend\Http\Client;
$client->setAdapter("Zend\Http\Client\Adapter\Curl");
$response = $client->dispatch($request);
問題是從控制檯運行時,這將引發一個cookie異常:
POST http://somesite.com HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
hello=world
======================================================================
The application has thrown an exception!
======================================================================
Zend\Http\Header\Exception\InvalidArgumentException
Cookie name cannot contain these characters: =,; \t\r\n\013\014 (WEBUK=)
如果任何人都可以指出如何解決這個問題,我將非常感激。
該代碼在正常路由OKAY中工作......它只是在我從控制檯運行它時抱怨cookie問題。