当前位置: 首页>>代码示例>>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;未经允许,请勿转载。