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


PHP Response::getReasonPhrase方法代码示例

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


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

示例1: testCanConstructWithReason

 public function testCanConstructWithReason()
 {
     $r = new Response(200, [], null, '1.1', 'bar');
     $this->assertSame('bar', $r->getReasonPhrase());
     $r = new Response(200, [], null, '1.1', '0');
     $this->assertSame('0', $r->getReasonPhrase(), 'Falsey reason works');
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:7,代码来源:ResponseTest.php

示例2: testCanCreateNewResponseWithStatusAndReason

 public function testCanCreateNewResponseWithStatusAndReason()
 {
     $r = new Response(200);
     $r2 = $r->withStatus(201, 'Foo');
     $this->assertEquals(200, $r->getStatusCode());
     $this->assertEquals('OK', $r->getReasonPhrase());
     $this->assertEquals(201, $r2->getStatusCode());
     $this->assertEquals('Foo', $r2->getReasonPhrase());
 }
开发者ID:shomimn,项目名称:builder,代码行数:9,代码来源:ResponseTest.php

示例3: out

/**
 * @param Response $response
 */
function out(Response $response)
{
    header(sprintf('%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()));
    foreach ($response->getHeaders() as $name => $values) {
        foreach ($values as $value) {
            header(sprintf('%s: %s', $name, $value), false);
        }
    }
    stream_copy_to_stream(\GuzzleHttp\Psr7\StreamWrapper::getResource($response->getBody()), fopen('php://output', 'w'));
}
开发者ID:creios,项目名称:creiwork-framework,代码行数:13,代码来源:functions.php

示例4: getSerializedResponse

 protected function getSerializedResponse(Response $response)
 {
     $cached = new \SplFixedArray(5);
     $cached[0] = $response->getStatusCode();
     $cached[1] = $response->getHeaders();
     $cached[2] = $response->getBody()->__toString();
     $cached[3] = $response->getProtocolVersion();
     $cached[4] = $response->getReasonPhrase();
     return serialize($cached);
 }
开发者ID:AlliterativeAnimals,项目名称:GuzzleHttpBundle,代码行数:10,代码来源:CurlMultiHandler.php

示例5: createException

 /**
  * @param Response $response
  *
  * @throws \LogicException
  */
 protected static function createException(Response $response)
 {
     $content = json_decode($response->getBody()->getContents(), true);
     if (is_array($content) && array_key_exists('errors', $content)) {
         $message = json_encode($content['errors'], JSON_UNESCAPED_UNICODE);
     } else {
         $message = $response->getReasonPhrase();
     }
     throw new \LogicException($message, $response->getStatusCode());
 }
开发者ID:worldia,项目名称:textmaster-api,代码行数:15,代码来源:ResponseMediator.php

示例6: checkResponse

 /**
  * @param Response $response
  *
  * @throws FenrirApiException When Fenrir Api return a non success status code.
  */
 private static function checkResponse(Response $response)
 {
     $statusCode = $response->getStatusCode();
     if ($statusCode >= 400 && $statusCode < 600) {
         $reason = $response->getReasonPhrase();
         $body = json_decode($response->getBody());
         if (isset($body->error->exception[0]->message)) {
             $reason = $body->error->exception[0]->message;
         }
         throw new FenrirApiException($statusCode, $reason);
     }
 }
开发者ID:canaltp,项目名称:fenrir-api-client,代码行数:17,代码来源:FenrirApi.php

示例7: make

 public static function make(Response $response)
 {
     $code = $response->getStatusCode();
     $body = json_decode($response->getBody(), true);
     if ($response->getStatusCode() == 200) {
         if (!is_array($body) && is_string($body)) {
             $body = ['message' => $body];
         }
     } else {
         if (!$body['message']) {
             $body = ['message' => $response->getReasonPhrase(), 'details' => $body];
         }
     }
     return new RuleResponse($code, $body);
 }
开发者ID:rulecom,项目名称:api-wrapper,代码行数:15,代码来源:ResponseFactory.php

示例8: doExecute

 /**
  * Executes a Psr\Http\Message\RequestInterface
  *
  * @param Google_Client $client
  * @param Psr\Http\Message\RequestInterface $request
  * @return array decoded result
  * @throws Google_Service_Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
 {
     try {
         $httpHandler = HttpHandlerFactory::build($client);
         $response = $httpHandler($request);
     } catch (RequestException $e) {
         // if Guzzle throws an exception, catch it and handle the response
         if (!$e->hasResponse()) {
             throw $e;
         }
         $response = $e->getResponse();
         // specific checking for Guzzle 5: convert to PSR7 response
         if ($response instanceof \GuzzleHttp\Message\ResponseInterface) {
             $response = new Response($response->getStatusCode(), $response->getHeaders() ?: [], $response->getBody(), $response->getProtocolVersion(), $response->getReasonPhrase());
         }
     }
     return self::decodeHttpResponse($response, $request, $expectedClass);
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:27,代码来源:REST.php

示例9: sendResponse

 /**
  * Will send the response, standard PHP way
  * 
  * @param Response $response
  * @return null
  */
 public function sendResponse($response)
 {
     header("HTTP/" . $response->getProtocolVersion() . " " . $response->getStatusCode() . " " . $response->getReasonPhrase());
     foreach ($response->getHeaders() as $name => $values) {
         foreach ($values as $value) {
             header(sprintf('%s: %s', $name, $value), false);
         }
     }
     $body = $response->getBody();
     while (!$body->eof()) {
         $buf = $body->read(1048576);
         // Using a loose equality here to match on '' and false.
         if ($buf == null) {
             break;
         } else {
             echo $buf;
         }
     }
 }
开发者ID:frodeborli,项目名称:fubberframework,代码行数:25,代码来源:Kernel.php

示例10: isValidResponse

 /**
  * @internal
  *
  * @param $response
  *
  * @return bool
  */
 public function isValidResponse(GuzzleResponse $response)
 {
     return $response->getReasonPhrase() != 'OK' || $response->getStatusCode() != 200;
 }
开发者ID:brozot,项目名称:laravel-fcm,代码行数:11,代码来源:FCMGroup.php

示例11: formatGuzzleResponse

 /**
  * Formate guzzle response data.
  *
  * @param $response \GuzzleHttp\Psr7\Response
  *
  * @return stdClass
  */
 public function formatGuzzleResponse(\GuzzleHttp\Psr7\Response $response)
 {
     return (object) array('statusCode' => $response->getStatusCode(), 'reasonPhrase' => $response->getReasonPhrase(), 'content' => $response->getBody()->getContents());
 }
开发者ID:vooodoo,项目名称:mailjetbundle,代码行数:11,代码来源:AbstractRequest.php

示例12: __construct

 public function __construct(Response $response)
 {
     parent::__construct($response->getReasonPhrase());
     $this->response = $response;
 }
开发者ID:jobsity,项目名称:php-tick,代码行数:5,代码来源:ApiException.php

示例13: getReasonPhrase

 /**
  * Gets the response reason phrase associated with the status code.
  *
  * @return string
  */
 public function getReasonPhrase()
 {
     return $this->response->getReasonPhrase();
 }
开发者ID:hedii,项目名称:zotero-api,代码行数:9,代码来源:ZoteroApi.php

示例14: cacheResponse

 /**
  * Cache response
  *
  * @param RequestInterface $request
  * @param Response         $response
  * @param int              $ttl
  *
  * @return booelan
  */
 protected function cacheResponse(RequestInterface $request, Response $response, $ttl = null)
 {
     if (!$this->isSupportedMethod($request)) {
         return;
     }
     // copy response in array to  store
     $cached = new \SplFixedArray(5);
     $cached[0] = $response->getStatusCode();
     $cached[1] = $response->getHeaders();
     $cached[2] = $response->getBody()->__toString();
     $cached[3] = $response->getProtocolVersion();
     $cached[4] = $response->getReasonPhrase();
     return $this->cache->set(self::getKey($request), serialize($cached), $ttl ?: $this->getCachettl($response));
 }
开发者ID:AlliterativeAnimals,项目名称:GuzzleHttpBundle,代码行数:23,代码来源:CacheTrait.php

示例15: assertResponse

 /**
  * @param Response $response
  */
 protected function assertResponse(Response $response)
 {
     Assertion::inArray($response->getStatusCode(), [200, 201, 202, 409], sprintf('Failed request [%s]: %s', $response->getStatusCode(), $response->getReasonPhrase()));
 }
开发者ID:mhwk,项目名称:spray-ouro,代码行数:7,代码来源:CreatePersistentSubscriptionHandler.php


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