当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getHeaders方法代码示例

本文整理汇总了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'));
 }
开发者ID:aptoma,项目名称:silex-extras,代码行数:13,代码来源:RequestTokenPluginTest.php

示例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'));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:18,代码来源:RequestTest.php

示例3: getHeaders

 public function getHeaders()
 {
     return $this->_request->getHeaders()->toArray();
 }
开发者ID:sokil,项目名称:php-rest,代码行数:4,代码来源:Request.php

示例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'));
 }
开发者ID:security-geeks,项目名称:squert,代码行数:14,代码来源:GuzzleConnection.php


注:本文中的Guzzle\Http\Message\Request::getHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。