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


PHP Response::getHeaders方法代码示例

本文整理汇总了PHP中Buzz\Message\Response::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getHeaders方法的具体用法?PHP Response::getHeaders怎么用?PHP Response::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Buzz\Message\Response的用法示例。


在下文中一共展示了Response::getHeaders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processResponse

 private function processResponse(Response $response)
 {
     $this->logger->info('Response:' . $response);
     if (500 <= $response->getStatusCode()) {
         throw new ApiServerException($response->getStatusCode(), $response->getContent(), $response->getReasonPhrase(), $response->getHeaders());
     }
     if (400 <= $response->getStatusCode()) {
         try {
             $error = $this->parser->parse($response->getContent());
             $error = $error instanceof Model\Error ? $error : new Model\Error();
         } catch (ApiParserException $e) {
             throw new ApiClientException($response->getStatusCode(), $response->getContent(), $response->getReasonPhrase(), $response->getHeaders(), null, $e);
         }
         throw new ApiClientException($response->getStatusCode(), $response->getContent(), $response->getReasonPhrase(), $response->getHeaders(), $error);
     }
     if (204 === $response->getStatusCode()) {
         return true;
     }
     $content = trim($response->getContent());
     if (empty($content)) {
         return true;
     }
     $object = $this->parser->parse($content);
     $object->setApi($this);
     return $object;
 }
开发者ID:KinaMarie,项目名称:connect,代码行数:26,代码来源:Api.php

示例2: processResponse

 private function processResponse(Response $response)
 {
     if (null !== $this->logger) {
         $this->logger->info(sprintf('Status Code %s', $response->getStatusCode()));
         $this->logger->debug(var_export($response->getContent(), true));
     }
     if (500 <= $response->getStatusCode()) {
         throw new ApiServerException($response->getStatusCode(), $response->getContent(), $response->getReasonPhrase(), $response->getHeaders());
     }
     if (400 <= $response->getStatusCode()) {
         throw new ApiClientException($response->getStatusCode(), $response->getContent(), $response->getReasonPhrase(), $response->getHeaders());
     }
     if (204 === $response->getStatusCode()) {
         return true;
     }
     if (null !== $response->getContent()) {
         $object = $this->parser->parse($response->getContent());
         $object->setApi($this);
         return $object;
     }
 }
开发者ID:nfabre,项目名称:connect,代码行数:21,代码来源:Api.php

示例3: convertResponse

 /**
  * Converts a buzz response to a pinterest response.
  *
  * @param Request      $request      The request.
  * @param BuzzResponse $buzzResponse The buzz response.
  *
  * @return Response The response.
  */
 private static function convertResponse(Request $request, BuzzResponse $buzzResponse)
 {
     $statusCode = $buzzResponse->getStatusCode();
     $rawBody = (string) $buzzResponse->getContent();
     $rawHeaders = $buzzResponse->getHeaders();
     $headers = array();
     foreach ($rawHeaders as $header) {
         if (stristr($header, 'HTTP/1.')) {
             continue;
         }
         list($key, $value) = explode(': ', $header);
         $headers[$key] = $value;
     }
     return new Response($request, $statusCode, $rawBody, $headers);
 }
开发者ID:hansott,项目名称:pinterest-php,代码行数:23,代码来源:BuzzClient.php

示例4: testFromString

    public function testFromString()
    {
        $content = <<<EOF
This is the body.

More body!

EOF;
        $response = new Response();
        $response->fromString(<<<EOF
HTTP/1.0 200 OK
Content-Type: text/plain

{$content}
EOF
);
        $this->assertEquals(2, count($response->getHeaders()));
        $this->assertEquals($content, $response->getContent());
    }
开发者ID:kingsj,项目名称:core,代码行数:19,代码来源:ResponseTest.php

示例5: getBuzzHeaders

 /**
  * Get headers from a Buzz response.
  *
  * @param BuzzResponse $response
  *
  * @return array
  */
 private function getBuzzHeaders(BuzzResponse $response)
 {
     $buzzHeaders = $response->getHeaders();
     unset($buzzHeaders[0]);
     $headers = [];
     foreach ($buzzHeaders as $headerLine) {
         list($name, $value) = explode(':', $headerLine, 2);
         $headers[$name] = trim($value);
     }
     return $headers;
 }
开发者ID:php-http,项目名称:buzz-adapter,代码行数:18,代码来源:Client.php

示例6: getHeaders

 /**
  * Get all response headers.
  *
  * @return array Associative array with $header => $value (value can be an array if it hasn't a single value)
  *
  * @throws \RuntimeException If request hasn't been send already
  */
 public function getHeaders()
 {
     return $this->unFormatHeaders($this->response->getHeaders());
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:11,代码来源:BuzzDriver.php


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