當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::getStatusCode方法代碼示例

本文整理匯總了PHP中Illuminate\Http\Response::getStatusCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::getStatusCode方法的具體用法?PHP Response::getStatusCode怎麽用?PHP Response::getStatusCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Http\Response的用法示例。


在下文中一共展示了Response::getStatusCode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: serialize

 /**
  * Serialize a response.
  *
  * @param \Illuminate\Http\Response $response
  *
  * @return string
  */
 public function serialize(Response $response)
 {
     $content = $response->getContent();
     $statusCode = $response->getStatusCode();
     $headers = $response->headers;
     return serialize(compact('content', 'statusCode', 'headers'));
 }
開發者ID:sdebacker,項目名稱:laravel-responsecache,代碼行數:14,代碼來源:ResponseSerializer.php

示例2: render

 /**
  * Render an exception into a response.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Exception $exception
  * @return \Illuminate\Http\Response
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function render($request, Exception $exception)
 {
     $response = (new SymfonyExceptionHandler(env('APP_DEBUG', false)))->createResponse($exception);
     $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
     $response->exception = $exception;
     return $response;
 }
開發者ID:hrslash,項目名稱:luminous,代碼行數:16,代碼來源:Handler.php

示例3: makeMessageFromResponse

 protected function makeMessageFromResponse(Response $response)
 {
     $message['original_content'] = $response->getOriginalContent();
     $message['content'] = $response->getContent();
     $message['status_code'] = $response->getStatusCode();
     return json_encode($message, JSON_PRETTY_PRINT);
 }
開發者ID:alfred-nutile-inc,項目名稱:incomings-client,代碼行數:7,代碼來源:IncomingsMiddleWare.php

示例4: makeFromExisting

 /**
  * Make an API response from an existing response object.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @param  \Illuminate\Http\Response $old
  * @return \Nodes\Api\Http\Response
  */
 public static function makeFromExisting(IlluminateResponse $old)
 {
     // Support for custom status code and message
     $statusCode = $old instanceof self ? $old->getStatusCodeAndMessage() : $old->getStatusCode();
     // Generate API response from response object
     $new = static::create($old->getOriginalContent(), $statusCode);
     $new->headers = $old->headers;
     return $new;
 }
開發者ID:nodes-php,項目名稱:api,代碼行數:17,代碼來源:Response.php

示例5: assertPageLoaded

 /**
  * Assert that a given page successfully loaded.
  *
  * @param  string $uri
  * @param  string|null $message
  *
  */
 protected function assertPageLoaded($uri, $message = null)
 {
     $status = $this->response->getStatusCode();
     try {
         $this->assertEquals(200, $status);
     } catch (PHPUnitException $e) {
         $message = $message ?: "A request to [{$uri}] failed. Received status code [{$status}].";
         throw new HttpException($message, null, $this->response->exception);
     }
 }
開發者ID:sellerlabs,項目名稱:illuminated,代碼行數:17,代碼來源:CrawlerTrait.php

示例6: filter

 /**
  * Allow Lassy to save only valid html responses
  *
  * @param \Illuminate\Http\Response $response
  * @return boolean
  */
 public function filter(Response $response)
 {
     if (200 !== $response->getStatusCode()) {
         return false;
     }
     if (false === strpos($response->headers->get('Content-Type'), 'text/html')) {
         return false;
     }
     return true;
 }
開發者ID:radmen,項目名稱:lassy,代碼行數:16,代碼來源:HtmlResponse.php

示例7: renderPretty

 /**
  * Return an ajax or prettify with whoops.
  *
  * @param  Exception $e
  * @param  \Illuminate\Http\Request    $request
  * @param  \Illuminate\Http\Response    $response
  *
  * @return mixed
  */
 public function renderPretty(Exception $e, $request, $response)
 {
     if ($this->areYouAnAjax($request)) {
         $res = [];
         $res['status'] = 'error';
         $res['message'] = empty($e->getMessage()) ? $response::$statusTexts[$response->getStatusCode()] : $e->getMessage();
         $res['file'] = $e->getFile();
         $res['line'] = $e->getLine();
         $res['statusCode'] = $response->getStatusCode();
         $res['statusText'] = $response::$statusTexts[$response->getStatusCode()];
         $res['error'] = $res;
         return $response->setContent($res);
     } else {
         if (view()->exists('errors.' . $response->getStatusCode())) {
             return response()->view('errors.' . $response->getStatusCode(), compact('response'));
         }
         $whoops = (new Run())->pushHandler(new PrettyPageHandler());
         return $whoops->handleException($e);
     }
 }
開發者ID:multimedia-street,項目名稱:common,代碼行數:29,代碼來源:Handler.php

示例8: after

 /**
  * Module after response hook.
  *
  * @param \Illuminate\Foundation\Application $app
  * @param \Illuminate\Http\Response          $response
  *
  * @return void
  */
 public function after(Application $app, $response)
 {
     $this->data['id'] = $app->make(Agent::class)->getKey();
     $this->data['versions']['php'] = phpversion();
     $this->data['versions']['laravel'] = Application::VERSION;
     $this->data['environment'] = $app->config->get('app.env');
     $this->data['http']['path'] = $app->request->path();
     $this->data['http']['method'] = $app->request->method();
     $this->data['http']['status'] = $response->getStatusCode();
     $this->data['time']['start'] = LARAVEL_START;
     $this->data['time']['end'] = microtime(true);
     $this->data['time']['total'] = microtime(true) - LARAVEL_START;
     $this->data['memory'] = memory_get_peak_usage();
 }
開發者ID:daylerees,項目名稱:anbu-agent,代碼行數:22,代碼來源:GeneralModule.php

示例9: setResponse

 /**
  * @param Response $response
  */
 public function setResponse(Response $response)
 {
     $this->response = $response;
     $statusCode = $this->response->getStatusCode();
     if ($statusCode >= 300 && $this->debug_mode) {
         echo "\nResponse STATUS CODE is {$statusCode}:\n";
         $responseData = $this->getResponseData();
         if ($responseData) {
             $this->printArray($responseData);
         } else {
             $this->printLine($this->getResponse());
         }
     }
 }
開發者ID:someline,項目名稱:rest-api-client,代碼行數:17,代碼來源:RestClient.php

示例10: assertResponseStatus

 /**
  * Assert that the client response has a given code.
  *
  * @param  int  $code
  * @return $this
  */
 public function assertResponseStatus($code)
 {
     $actual = $this->response->getStatusCode();
     PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}.");
     return $this;
 }
開發者ID:scrubmx,項目名稱:framework,代碼行數:12,代碼來源:MakesHttpRequests.php

示例11: seeStatusCode

 /**
  * Asserts that the status code of the response matches the given code.
  *
  * @param  int  $status
  * @return $this
  */
 protected function seeStatusCode($status)
 {
     $this->assertEquals($status, $this->response->getStatusCode());
     return $this;
 }
開發者ID:ncusoho,項目名稱:framework,代碼行數:11,代碼來源:CrawlerTrait.php

示例12: __construct

 /**
  * Create a new internal HTTP exception instance.
  *
  * @param \Illuminate\Http\Response $response
  * @param string                    $message
  * @param \Exception                $previous
  * @param array                     $headers
  * @param int                       $code
  *
  * @return void
  */
 public function __construct(Response $response, $message = null, Exception $previous = null, array $headers = [], $code = 0)
 {
     $this->response = $response;
     parent::__construct($response->getStatusCode(), $message, $previous, $headers, $code);
 }
開發者ID:jieke360,項目名稱:api,代碼行數:16,代碼來源:InternalHttpException.php

示例13: toIlluminateResponse

 /**
  * Map exception into an illuminate response.
  *
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 protected function toIlluminateResponse($response, Exception $e)
 {
     $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
     $response->exception = $e;
     return $response;
 }
開發者ID:hilmysyarif,項目名稱:sisfito,代碼行數:13,代碼來源:Handler.php

示例14: makeFromExisting

 /**
  * Make an API response from an existing Illuminate response.
  *
  * @param \Illuminate\Http\Response $old
  *
  * @return \Dingo\Api\Http\Response
  */
 public static function makeFromExisting(IlluminateResponse $old)
 {
     $new = static::create($old->getOriginalContent(), $old->getStatusCode());
     $new->headers = $old->headers;
     return $new;
 }
開發者ID:JamesGuthrie,項目名稱:api,代碼行數:13,代碼來源:Response.php

示例15: shouldCache

 /**
  * Determines whether the given request/response should be cached.
  *
  * @param  \Illuminate\Http\Response  $response
  * @return bool
  */
 protected function shouldCache($request, $response)
 {
     return $request->isMethod('GET') && $response->getStatusCode() == 200;
 }
開發者ID:matriphe,項目名稱:laravel.com,代碼行數:10,代碼來源:CacheResponse.php


注:本文中的Illuminate\Http\Response::getStatusCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。