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


PHP Response::getReasonPhrase方法代码示例

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


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

示例1: debug

 public function debug()
 {
     $r = new Response();
     var_dump($r->getReasonPhrase());
     $req = new Request();
     $req->getPath();
 }
开发者ID:arthurwayne,项目名称:ovh-sdk-php,代码行数:7,代码来源:VoiceConsumptionException.php

示例2: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     if (!static::isValidIntercomError($response->json())) {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response->json())) {
         $e->setErrors($response->json()['errors']);
     }
     return $e;
 }
开发者ID:atlir,项目名称:intercom-php,代码行数:32,代码来源:IntercomException.php

示例3: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $response_json = $response->json();
     $intercom_unavailable_error = NULL;
     if (!static::isValidIntercomError($response_json)) {
         if ($response->isServerError()) {
             $label = 'Server error response';
             $class = __NAMESPACE__ . '\\ServerErrorResponseException';
             $intercom_unavailable_error = 'Service Unavailable: Back-end server is at capacity';
         } else {
             $label = 'Unsuccessful response';
             $class = __CLASS__;
         }
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response_json)) {
         $e->setErrors($response_json['errors']);
     } elseif ($intercom_unavailable_error != NULL) {
         $e->setErrors(array('code' => 'service_unavailable', "message" => $intercom_unavailable_error));
     }
     return $e;
 }
开发者ID:scup,项目名称:intercom-php,代码行数:42,代码来源:IntercomException.php

示例4: factory

 /**
  * Factory method to create a new Oauth exception.
  *
  * @param RequestInterface $request
  * @param Response $response
  *
  * @return OauthException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new static($message);
     $e->setResponse($response);
     $e->setRequest($request);
     return $e;
 }
开发者ID:cpliakas,项目名称:magento-client-php,代码行数:16,代码来源:OauthException.php

示例5: parseHeaders

 /**
  * Parses additional exception information from the response headers
  *
  * @param RequestInterface $request  Request that was issued
  * @param Response         $response The response from the request
  * @param array            $data     The current set of exception data
  */
 protected function parseHeaders(RequestInterface $request, Response $response, array &$data)
 {
     $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
     if ($requestId = $response->getHeader('x-amz-request-id')) {
         $data['request_id'] = $requestId;
         $data['message'] .= " (Request-ID: {$requestId})";
     }
 }
开发者ID:skinnard,项目名称:FTL-2,代码行数:15,代码来源:DefaultXmlExceptionParser.php

示例6: prepareResponse

 protected function prepareResponse(Response $data)
 {
     if ($data->getStatusCode() != 200) {
         throw new \InvalidArgumentException($data->getReasonPhrase());
     }
     $response = json_decode($data->getBody(), true);
     $this->validateResponse($response);
     return $response;
 }
开发者ID:tripda,项目名称:ring-captcha,代码行数:9,代码来源:RingCaptcha.php

示例7: createResponse

 /**
  * Prepares an EmbeddedResponse from the original response and data
  *
  * @param Guzzle\Http\Message\Response $originalResponse
  * @param array                        $data
  *
  * @return Desk\Relationship\Resource\EmbeddedResponse
  */
 public function createResponse(Response $originalResponse, array $data)
 {
     $statusCode = $originalResponse->getStatusCode();
     $reasonPhrase = $originalResponse->getReasonPhrase();
     $headers = $originalResponse->getHeaders();
     $body = json_encode($data);
     // set reason phrase -- needs to be done vie
     $response = $this->newResponse($statusCode, $headers, $body);
     $response->setReasonPhrase($reasonPhrase);
     return $response;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:19,代码来源:EmbeddedCommandFactory.php

示例8: factory

 public static function factory(RequestInterface $request, Response $response)
 {
     $label = 'Bearer error response';
     $bearerReason = self::headerToReason($response->getHeader("WWW-Authenticate"));
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[bearer reason] ' . $bearerReason, '[url] ' . $request->getUrl()));
     $e = new static($message);
     $e->setResponse($response);
     $e->setRequest($request);
     $e->setBearerReason($bearerReason);
     return $e;
 }
开发者ID:Farik2605,项目名称:tobi,代码行数:11,代码来源:BearerErrorResponseException.php

示例9: factory

 /**
  * Factory method to create a new response exception based on the response code.
  *
  * @param RequestInterface $request  Request
  * @param Response         $response Response received
  * @param string           $label
  *
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response, $label = null)
 {
     if (!$label) {
         if ($response->isClientError()) {
             $label = 'Client error response';
         } elseif ($response->isServerError()) {
             $label = 'Server error response';
         } else {
             $label = 'Unsuccessful response';
         }
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl(), '[content type] ' . $response->getContentType(), '[response body] ' . $response->getBody(true)));
     $result = new static($message);
     $result->setResponse($response);
     $result->setRequest($request);
     return $result;
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:26,代码来源:BadResponseException.php

示例10: factory

 public static function factory(RequestInterface $request, Response $response)
 {
     if ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new self($message);
     $e->setResponse($response);
     $e->setRequest($request);
     return $e;
 }
开发者ID:karllhughes,项目名称:clearbit-php,代码行数:18,代码来源:BadResponseException.php

示例11: format

 /**
  * Returns a formatted message
  *
  * @param RequestInterface $request    Request that was sent
  * @param Response         $response   Response that was received
  * @param CurlHandle       $handle     Curl handle associated with the message
  * @param array            $customData Associative array of custom template data
  *
  * @return string
  */
 public function format(RequestInterface $request, Response $response = null, CurlHandle $handle = null, array $customData = array())
 {
     $cache = $customData;
     return preg_replace_callback('/{\\s*([A-Za-z_\\-\\.0-9]+)\\s*}/', function (array $matches) use($request, $response, $handle, &$cache) {
         if (array_key_exists($matches[1], $cache)) {
             return $cache[$matches[1]];
         }
         $result = '';
         switch ($matches[1]) {
             case 'request':
                 $result = (string) $request;
                 break;
             case 'response':
                 $result = (string) $response;
                 break;
             case 'req_body':
                 $result = $request instanceof EntityEnclosingRequestInterface ? (string) $request->getBody() : '';
                 break;
             case 'res_body':
                 $result = $response ? $response->getBody(true) : '';
                 break;
             case 'ts':
                 $result = gmdate('c');
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = (string) $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'protocol':
                 $result = 'HTTP';
                 break;
             case 'version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'port':
                 $result = $request->getPort();
                 break;
             case 'code':
                 $result = $response ? $response->getStatusCode() : '';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : '';
                 break;
             case 'connect_time':
                 if ($handle) {
                     $result = $handle->getInfo(CURLINFO_CONNECT_TIME);
                 } elseif ($response) {
                     $result = $response->getInfo('connect_time');
                 }
                 break;
             case 'total_time':
                 if ($handle) {
                     $result = $handle->getInfo(CURLINFO_TOTAL_TIME);
                 } elseif ($response) {
                     $result = $response->getInfo('total_time');
                 }
                 break;
             case 'curl_error':
                 $result = $handle ? $handle->getError() : '';
                 break;
             case 'curl_code':
                 $result = $handle ? $handle->getErrorNo() : '';
                 break;
             case 'curl_stderr':
                 $result = $handle ? $handle->getStderr() : '';
                 break;
             default:
                 if (strpos($matches[1], 'req_header_') === 0) {
                     $result = $request->getHeader(substr($matches[1], 11));
                 } elseif (strpos($matches[1], 'res_header_') === 0) {
                     $result = $response->getHeader(substr($matches[1], 11));
                 }
         }
         $cache[$matches[1]] = $result;
         return $result;
     }, $this->template);
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:98,代码来源:MessageFormatter.php

示例12: testHandlesStatusAndStatusCodes

 /**
  * @covers Guzzle\Http\Message\Response::getReasonPhrase
  * @covers Guzzle\Http\Message\Response::setStatus
  */
 public function testHandlesStatusAndStatusCodes()
 {
     $response = new Response(200, new Collection(), 'body');
     $this->assertEquals('OK', $response->getReasonPhrase());
     $this->assertSame($response, $response->setStatus(204));
     $this->assertEquals('No Content', $response->getReasonPhrase());
     $this->assertEquals(204, $response->getStatusCode());
     $this->assertSame($response, $response->setStatus(204, 'Testing!'));
     $this->assertEquals('Testing!', $response->getReasonPhrase());
     $this->assertEquals(204, $response->getStatusCode());
     try {
         $response->setStatus(2000);
         $this->fail('Did not throw expected exception when setting an invalid status');
     } catch (BadResponseException $e) {
     }
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:20,代码来源:ResponseTest.php

示例13: visit

 public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
 {
     $value[$param->getName()] = $response->getReasonPhrase();
 }
开发者ID:nstanard,项目名称:webpagetest,代码行数:4,代码来源:ReasonPhraseVisitor.php

示例14: testHandlesStatusAndStatusCodes

 /**
  * @covers Guzzle\Http\Message\Response::getReasonPhrase
  * @covers Guzzle\Http\Message\Response::setStatus
  */
 public function testHandlesStatusAndStatusCodes()
 {
     $response = new Response(200, new Collection(), 'body');
     $this->assertEquals('OK', $response->getReasonPhrase());
     $this->assertSame($response, $response->setStatus(204));
     $this->assertEquals('No Content', $response->getReasonPhrase());
     $this->assertEquals(204, $response->getStatusCode());
     $this->assertSame($response, $response->setStatus(204, 'Testing!'));
     $this->assertEquals('Testing!', $response->getReasonPhrase());
     $this->assertEquals(204, $response->getStatusCode());
     $response->setStatus(2000);
     $this->assertEquals(2000, $response->getStatusCode());
     $this->assertEquals('', $response->getReasonPhrase());
     $response->setStatus(200, 'Foo');
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('Foo', $response->getReasonPhrase());
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:21,代码来源:ResponseTest.php

示例15: getDelay

protected function getDelay($retries, RequestInterface $request, Response $response = null, HttpException $e = null)
{
if ($response) {
return isset($this->errorCodes[$response->getReasonPhrase()]) ? true : null;
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:6,代码来源:ReasonPhraseBackoffStrategy.php


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