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


PHP Misc::canSendHeaders方法代码示例

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


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

示例1: handle

 public function handle()
 {
     if (!$this->isAjaxRequest()) {
         return Handler::DONE;
     }
     $display = Config::get('concrete.debug.display_errors');
     if (!$display) {
         $error = array('message' => t('An error occurred while processing this request.'));
     } else {
         $detail = Config::get('concrete.debug.detail', 'message');
         if ($detail !== 'debug') {
             $e = $this->getInspector()->getException();
             $error = array('message' => $e->getMessage());
         } else {
             $error = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
         }
     }
     $response = array('error' => $error, 'errors' => array($error['message']));
     if (Misc::canSendHeaders()) {
         if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
             header('Content-Type: application/json; charset=' . APP_CHARSET, true);
         } else {
             header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
         }
     }
     echo json_encode($response);
     return Handler::QUIT;
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:28,代码来源:JsonErrorHandler.php

示例2: handle

 public function handle()
 {
     if (!$this->isAjaxRequest()) {
         return Handler::DONE;
     }
     $ex = $this->getException();
     if ($ex instanceof UserException) {
         $obj = ['message' => $ex->getMessage(), 'code' => $ex->getUserErrorCode(), 'status' => $ex->getCode()];
     } else {
         if ($this->debug) {
             $obj = ['message' => $ex->getMessage(), 'code' => $ex->getCode(), 'status' => 500];
         } else {
             $obj = ['message' => 'Server internal error', 'code' => -1, 'status' => 500];
         }
     }
     if ($this->debug) {
         $obj['detail'] = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
     }
     $this->getRun()->sendHttpCode($obj['status']);
     if (Misc::canSendHeaders()) {
         header('Content-Type: application/json');
     }
     echo json_encode($obj);
     return Handler::QUIT;
 }
开发者ID:Tanklong,项目名称:openvj,代码行数:25,代码来源:JsonResponseHandler.php

示例3: handle

 /**
  * @return int
  */
 public function handle()
 {
     $response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
     if (\Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: application/json');
     }
     echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
     return Handler::QUIT;
 }
开发者ID:emac,项目名称:emacoo.cn,代码行数:12,代码来源:JsonResponseHandler.php

示例4: handle

 /**
  * @return int
  */
 public function handle()
 {
     if ($this->onlyForAjaxRequests() && !$this->isAjaxRequest()) {
         return Handler::DONE;
     }
     $response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
     if (\Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: application/json');
     }
     echo json_encode($response);
     return Handler::QUIT;
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:15,代码来源:JsonResponseHandler.php

示例5: handle

 /**
  * @return int
  */
 public function handle()
 {
     if (!$this->isAjaxRequest()) {
         return Handler::DONE;
     }
     $response = array('success' => false, 'data' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
     if (Misc::canSendHeaders()) {
         header('Content-Type: application/json; charset=' . get_option('blog_charset'));
     }
     $json_options = version_compare(PHP_VERSION, '5.4.0', '>=') ? JSON_PRETTY_PRINT : 0;
     echo wp_json_encode($response, $json_options);
     return Handler::QUIT;
 }
开发者ID:rarst,项目名称:wps,代码行数:16,代码来源:class-admin-ajax-handler.php

示例6: handle

 /**
  * @return int
  */
 public function handle()
 {
     if ($this->onlyForAjaxRequests() && !$this->isAjaxRequest()) {
         return \Whoops\Handler\Handler::DONE;
     }
     if ($this->onlyForJsonRequests() && !$this->isJsonRequest()) {
         return \Whoops\Handler\Handler::DONE;
     }
     $response = array('error' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()));
     unset($response['error']['file']);
     unset($response['error']['line']);
     $response['error']['code'] = $this->getException()->getCode();
     if (\Whoops\Util\Misc::canSendHeaders()) {
         http_response_code($response['error']['code']);
         header('Content-Type: application/json');
     }
     echo json_encode($response, defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? JSON_PARTIAL_OUTPUT_ON_ERROR : 0);
     return \Whoops\Handler\Handler::QUIT;
 }
开发者ID:riktamtech,项目名称:zf2-error-handler,代码行数:22,代码来源:JsonResponseHandler.php

示例7: handle

 public function handle()
 {
     $debug = Config::get('concrete.debug.level', 0);
     if ($debug !== DEBUG_DISPLAY_ERRORS) {
         return Handler::DONE;
     }
     if (!$this->isAjaxRequest()) {
         return Handler::DONE;
     }
     $error = Formatter::formatExceptionAsDataArray($this->getInspector(), true);
     $response = array('error' => $error, 'errors' => array($error['message']));
     if (\Whoops\Util\Misc::canSendHeaders()) {
         if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
             header('Content-Type: application/json; charset=' . APP_CHARSET, true);
         } else {
             header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
         }
     }
     echo json_encode($response);
     return Handler::QUIT;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:21,代码来源:JsonErrorHandler.php

示例8: writeToOutputNow

 /**
  * Echo something to the browser
  * @param  string $output
  * @return $this
  */
 private function writeToOutputNow($output)
 {
     if ($this->sendHttpCode() && \Whoops\Util\Misc::canSendHeaders()) {
         $httpCode = $this->sendHttpCode();
         if (function_exists('http_response_code')) {
             http_response_code($httpCode);
         } else {
             // http_response_code is added in 5.4.
             // For compatibility with 5.3 we use the third argument in header call
             // First argument must be a real header.
             // If it is empty, PHP will ignore the third argument.
             // If it is invalid, such as a single space, Apache will handle it well,
             // but the PHP development server will hang.
             // Setting a full status line would require us to hardcode
             // string values for all different status code, and detect the protocol.
             // which is an extra error-prone complexity.
             header('X-Ignore-This: 1', true, $httpCode);
         }
     }
     echo $output;
     return $this;
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:27,代码来源:Run.php

示例9: handle

 /**
  * @return int
  */
 public function handle()
 {
     if (!$this->canProcess()) {
         return Handler::DONE;
     }
     $exception = $this->getException();
     $response = sprintf("%s: %s in file %s on line %d%s\n", get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $this->getTraceOutput());
     if ($this->getLogger()) {
         $this->getLogger()->error($response);
     }
     if (!$this->canOutput()) {
         return Handler::DONE;
     }
     if (class_exists('\\Whoops\\Util\\Misc') && \Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: text/plain');
     }
     echo $response;
     return Handler::QUIT;
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:22,代码来源:PlainTextHandler.php

示例10: handle

 /**
  * @return int|null
  */
 public function handle()
 {
     if (!$this->handleUnconditionally()) {
         // Check conditions for outputting HTML:
         // @todo: Make this more robust
         if (php_sapi_name() === 'cli') {
             // Help users who have been relying on an internal test value
             // fix their code to the proper method
             if (isset($_ENV['whoops-test'])) {
                 throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable');
             }
             return Handler::DONE;
         }
     }
     // @todo: Make this more dynamic
     $helper = new TemplateHelper();
     $templateFile = $this->getResource("views/layout.html.php");
     $cssFile = $this->getResource("css/whoops.base.css");
     $zeptoFile = $this->getResource("js/zepto.min.js");
     $clipboard = $this->getResource("js/clipboard.min.js");
     $jsFile = $this->getResource("js/whoops.base.js");
     if ($this->customCss) {
         $customCssFile = $this->getResource($this->customCss);
     }
     $inspector = $this->getInspector();
     $frames = $inspector->getFrames();
     $code = $inspector->getException()->getCode();
     if ($inspector->getException() instanceof \ErrorException) {
         // ErrorExceptions wrap the php-error types within the "severity" property
         $code = Misc::translateErrorCode($inspector->getException()->getSeverity());
     }
     // List of variables that will be passed to the layout template.
     $vars = array("page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "clipboard" => file_get_contents($clipboard), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => explode("\\", $inspector->getExceptionName()), "message" => $inspector->getException()->getMessage(), "code" => $code, "plain_exception" => Formatter::formatExceptionPlain($inspector), "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => $this->getRun()->getHandlers(), "tables" => array("GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : array(), "Server/Request Data" => $_SERVER, "Environment Variables" => $_ENV));
     if (isset($customCssFile)) {
         $vars["stylesheet"] .= file_get_contents($customCssFile);
     }
     // Add extra entries list of data tables:
     // @todo: Consolidate addDataTable and addDataTableCallback
     $extraTables = array_map(function ($table) {
         return $table instanceof \Closure ? $table() : $table;
     }, $this->getDataTables());
     $vars["tables"] = array_merge($extraTables, $vars["tables"]);
     if (\Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: text/html');
     }
     $helper->setVariables($vars);
     $helper->render($templateFile);
     return Handler::QUIT;
 }
开发者ID:emac,项目名称:emacoo.cn,代码行数:52,代码来源:PrettyPageHandler.php

示例11: handle

    /**
     * @return int
     */
    public function handle()
    {
        if (!$this->canProcess()) {
            return Handler::DONE;
        }
        $exception = $this->getException();
        // $response = sprintf("%s: %s in file %s on line %d%s\n",
        //         get_class($exception),
        //         $exception->getMessage(),
        //         $exception->getFile(),
        //         $exception->getLine(),
        //         // $this->getTraceOutput()
        //         null
        //     );
        //var_dump($exception);
        // echo "1";
        if ($this->getLogger()) {
            $this->getLogger()->error($response);
        }
        if (!is_null($exception)) {
            $msg = $this->msg;
            $bg_color = $this->bg_color;
            //include_once '/core/Access/ErrorDisplayer/simple.php';
            ?>
                <head>
                    <meta charset="utf-8"/>
                    <title><?php 
            echo $msg;
            ?>
</title>
                    <style type="text/css">
                    body
                    {
                        background: #e9e9e9;
                        background: <?php 
            echo $bg_color;
            ?>
;
                        margin: 0px;
                        padding: 0px;
                    }

                    div 
                    {
                        box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.2);
                        border:1px solid gray;
                        border-radius:5px;
                        display: inline-block;
                        padding:30px;
                        font-size: 16px;
                        font: 20px Georgia, "Times New Roman", Times, serif;
                        width: 460px;
                        margin: 60px auto;
                        display: block;
                        background: white;
                    }
                    </style>

                </head>
                <body>
                    <div><?php 
            echo $msg;
            ?>
</div>
                </body>

                <?php 
        }
        return Handler::QUIT;
        if (!$this->canOutput()) {
            return Handler::DONE;
        }
        if (class_exists('\\Whoops\\Util\\Misc') && \Whoops\Util\Misc::canSendHeaders()) {
            //header('Content-Type: html/text');
        }
        //if(! is_null ($exception)) echo "fff";
        return Handler::QUIT;
    }
开发者ID:fiesta-framework,项目名称:whoops,代码行数:81,代码来源:PlainTextHandler.php

示例12: handle

 /**
  * @return int
  */
 public function handle()
 {
     if (!$this->canProcess()) {
         return Handler::DONE;
     }
     $exception = $this->getException();
     // $response = sprintf("%s: %s in file %s on line %d%s\n",
     //         get_class($exception),
     //         $exception->getMessage(),
     //         $exception->getFile(),
     //         $exception->getLine(),
     //         // $this->getTraceOutput()
     //         null
     //     );
     //var_dump($exception);
     // echo "1";
     if ($this->getLogger()) {
         $this->getLogger()->error($response);
     }
     if (!is_null($exception)) {
         $msg = $this->msg;
         $bg_color = $this->bg_color;
         include_once '../core/Access/ErrorDisplayer/simple.php';
     }
     return Handler::QUIT;
     if (!$this->canOutput()) {
         return Handler::DONE;
     }
     if (class_exists('\\Whoops\\Util\\Misc') && \Whoops\Util\Misc::canSendHeaders()) {
         //header('Content-Type: html/text');
     }
     //if(! is_null ($exception)) echo "fff";
     return Handler::QUIT;
 }
开发者ID:amineabri,项目名称:ARFiesta,代码行数:37,代码来源:PlainTextHandler.php

示例13: writeToOutputNow

 /**
  * Echo something to the browser
  * @param  string $output
  * @return $this
  */
 private function writeToOutputNow($output)
 {
     if ($this->sendHttpCode() && \Whoops\Util\Misc::canSendHeaders()) {
         $this->system->setHttpResponseCode($this->sendHttpCode());
     }
     echo $output;
     return $this;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:13,代码来源:Run.php

示例14: handle

 /**
  * @return int|null
  */
 public function handle()
 {
     if (!$this->handleUnconditionally()) {
         // Check conditions for outputting HTML:
         // @todo: Make this more robust
         if (php_sapi_name() === 'cli') {
             // Help users who have been relying on an internal test value
             // fix their code to the proper method
             if (isset($_ENV['whoops-test'])) {
                 throw new \Exception('Use handleUnconditionally instead of whoops-test' . ' environment variable');
             }
             return Handler::DONE;
         }
     }
     // @todo: Make this more dynamic
     $helper = new TemplateHelper();
     if (class_exists('Symfony\\Component\\VarDumper\\Cloner\\VarCloner')) {
         $cloner = new VarCloner();
         // Only dump object internals if a custom caster exists.
         $cloner->addCasters(['*' => function ($obj, $a, $stub, $isNested, $filter = 0) {
             $class = $stub->class;
             $classes = [$class => $class] + class_parents($class) + class_implements($class);
             foreach ($classes as $class) {
                 if (isset(AbstractCloner::$defaultCasters[$class])) {
                     return $a;
                 }
             }
             // Remove all internals
             return [];
         }]);
         $helper->setCloner($cloner);
     }
     $templateFile = $this->getResource("views/layout.html.php");
     $cssFile = $this->getResource("css/whoops.base.css");
     $zeptoFile = $this->getResource("js/zepto.min.js");
     $clipboard = $this->getResource("js/clipboard.min.js");
     $jsFile = $this->getResource("js/whoops.base.js");
     if ($this->customCss) {
         $customCssFile = $this->getResource($this->customCss);
     }
     $inspector = $this->getInspector();
     $frames = $inspector->getFrames();
     $code = $inspector->getException()->getCode();
     if ($inspector->getException() instanceof \ErrorException) {
         // ErrorExceptions wrap the php-error types within the "severity" property
         $code = Misc::translateErrorCode($inspector->getException()->getSeverity());
     }
     // Detect frames that belong to the application.
     if ($this->applicationPaths) {
         /* @var \Whoops\Exception\Frame $frame */
         foreach ($frames as $frame) {
             foreach ($this->applicationPaths as $path) {
                 if (substr($frame->getFile(), 0, strlen($path)) === $path) {
                     $frame->setApplication(true);
                     break;
                 }
             }
         }
     }
     // List of variables that will be passed to the layout template.
     $vars = ["page_title" => $this->getPageTitle(), "stylesheet" => file_get_contents($cssFile), "zepto" => file_get_contents($zeptoFile), "clipboard" => file_get_contents($clipboard), "javascript" => file_get_contents($jsFile), "header" => $this->getResource("views/header.html.php"), "header_outer" => $this->getResource("views/header_outer.html.php"), "frame_list" => $this->getResource("views/frame_list.html.php"), "frames_description" => $this->getResource("views/frames_description.html.php"), "frames_container" => $this->getResource("views/frames_container.html.php"), "panel_details" => $this->getResource("views/panel_details.html.php"), "panel_details_outer" => $this->getResource("views/panel_details_outer.html.php"), "panel_left" => $this->getResource("views/panel_left.html.php"), "panel_left_outer" => $this->getResource("views/panel_left_outer.html.php"), "frame_code" => $this->getResource("views/frame_code.html.php"), "env_details" => $this->getResource("views/env_details.html.php"), "title" => $this->getPageTitle(), "name" => explode("\\", $inspector->getExceptionName()), "message" => $inspector->getException()->getMessage(), "code" => $code, "plain_exception" => Formatter::formatExceptionPlain($inspector), "frames" => $frames, "has_frames" => !!count($frames), "handler" => $this, "handlers" => $this->getRun()->getHandlers(), "active_frames_tab" => count($frames) && $frames->offsetGet(0)->isApplication() ? 'application' : 'all', "has_frames_tabs" => $this->getApplicationPaths(), "tables" => ["GET Data" => $_GET, "POST Data" => $_POST, "Files" => $_FILES, "Cookies" => $_COOKIE, "Session" => isset($_SESSION) ? $_SESSION : [], "Server/Request Data" => $_SERVER, "Environment Variables" => $_ENV]];
     if (isset($customCssFile)) {
         $vars["stylesheet"] .= file_get_contents($customCssFile);
     }
     // Add extra entries list of data tables:
     // @todo: Consolidate addDataTable and addDataTableCallback
     $extraTables = array_map(function ($table) use($inspector) {
         return $table instanceof \Closure ? $table($inspector) : $table;
     }, $this->getDataTables());
     $vars["tables"] = array_merge($extraTables, $vars["tables"]);
     if (\Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: text/html');
     }
     $plainTextHandler = new PlainTextHandler();
     $plainTextHandler->setException($this->getException());
     $plainTextHandler->setInspector($this->getInspector());
     $vars["preface"] = "<!--\n\n\n" . $plainTextHandler->generateResponse() . "\n\n\n\n\n\n\n\n\n\n\n-->";
     $helper->setVariables($vars);
     $helper->render($templateFile);
     return Handler::QUIT;
 }
开发者ID:filp,项目名称:whoops,代码行数:84,代码来源:PrettyPageHandler.php

示例15: handle

 /**
  * @return int
  */
 public function handle()
 {
     $response = $this->generateResponse();
     if ($this->getLogger()) {
         $this->getLogger()->error($response);
     }
     if (!$this->canOutput()) {
         return Handler::DONE;
     }
     if (\Whoops\Util\Misc::canSendHeaders()) {
         header('Content-Type: text/plain');
     }
     echo $response;
     return Handler::QUIT;
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:18,代码来源:PlainTextHandler.php


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