本文整理汇总了PHP中Guzzle\Http\Message\Request::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getHeaders方法的具体用法?PHP Request::getHeaders怎么用?PHP Request::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::getHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testListenerShouldAppendToRemoteHeadersAddTokenHeader
public function testListenerShouldAppendToRemoteHeadersAddTokenHeader()
{
$token = 'foo';
$requestStack = new RequestStack();
$plugin = new RequestTokenPlugin($token, $requestStack);
$httpRequest = new \Symfony\Component\HttpFoundation\Request();
$httpRequest->headers->set('x-remote-request-token', 'bar');
$requestStack->push($httpRequest);
$guzzleRequest = new Request('GET', 'http://example.com');
$event = new Event(array('request' => $guzzleRequest));
$plugin->onBeforeRequestSend($event);
$this->assertEquals('bar foo', $guzzleRequest->getHeaders()->get('x-remote-request-token'));
}
示例2: testClonedRequestsUseNewInternalState
/**
* @covers Guzzle\Http\Message\Request::__clone
*/
public function testClonedRequestsUseNewInternalState()
{
$p = new AsyncPlugin();
$this->request->getEventDispatcher()->addSubscriber($p);
$h = $this->request->getHeader('Host');
$r = clone $this->request;
$this->assertEquals(RequestInterface::STATE_NEW, $r->getState());
$this->assertNotSame($r->getQuery(), $this->request->getQuery());
$this->assertNotSame($r->getCurlOptions(), $this->request->getCurlOptions());
$this->assertNotSame($r->getEventDispatcher(), $this->request->getEventDispatcher());
$this->assertEquals($r->getHeaders(), $this->request->getHeaders());
$this->assertNotSame($h, $r->getHeader('Host'));
$this->assertNotSame($r->getParams(), $this->request->getParams());
$this->assertTrue($this->request->getEventDispatcher()->hasListeners('request.sent'));
}
示例3: getHeaders
public function getHeaders()
{
return $this->_request->getHeaders()->toArray();
}
示例4: processSuccessfulRequest
/**
* @param Request $request
* @param string $body
*/
private function processSuccessfulRequest(Request $request, $body)
{
$response = $request->getResponse();
$headers = $request->getHeaders()->getAll();
$responseBody = $response->getBody(true);
$status = $response->getStatusCode();
$this->lastRequest['response']['body'] = $responseBody;
$this->lastRequest['response']['status'] = $status;
$this->logRequestSuccess($request->getMethod(), $request->getUrl(), $body, $headers, $status, $responseBody, $response->getInfo('total_time'));
}