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


PHP Zend_Controller_Response_Http::setHttpResponseCode方法代码示例

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


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

示例1: renderDebugOutput

 /**
  * Renders page-level debugging output and replaces the original view content
  * with it. Alternatively, it could inject itself into the view content.
  *
  * @param string $originalContent Original, rendered view content
  *
  * @return string Replacement rendered view content
  */
 public function renderDebugOutput($originalContent)
 {
     $this->_response->clearHeaders();
     $this->_response->setHttpResponseCode(200);
     $this->_response->setHeader('Content-Type', 'text/html; charset=UTF-8', true);
     $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
     return XenForo_Debug::getDebugPageWrapperHtml(XenForo_Debug::getDebugHtml());
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:16,代码来源:FrontController.php

示例2: _outputImage

 /**
  * Intercept a request for a cached image from the proxy and output it
  *
  * @param string|bool $error If non-false, an error that occurred when validating the request
  */
 protected function _outputImage($error)
 {
     if (empty(XenForo_Application::getOptions()->imageLinkProxy['images'])) {
         $error = 'disabled';
     }
     /* @var $proxyModel XenForo_Model_ImageProxy */
     $proxyModel = XenForo_Model::create('XenForo_Model_ImageProxy');
     $image = false;
     if (!$error) {
         $urlParts = parse_url($this->_url);
         if ($this->_isLocalHost($urlParts['host']) && (empty($_SERVER['SERVER_NAME']) || !$this->_isLocalHost($_SERVER['SERVER_NAME']))) {
             $error = 'local_url';
         }
     }
     if (!$error) {
         $image = $proxyModel->getImage($this->_url);
         if ($image) {
             $image = $proxyModel->prepareImage($image);
             if ($image['use_file']) {
                 $proxyModel->logImageView($image);
                 $eTag = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : null;
                 if ($eTag && $eTag == '"' . $image['fetch_date'] . '"') {
                     $this->_response->setHttpResponseCode(304);
                     $this->_response->clearHeader('Last-Modified');
                     $this->_response->sendHeaders();
                     return;
                 }
             } else {
                 $image = false;
                 $error = 'retrieve_failed';
             }
         }
     }
     if (!$image) {
         $image = $proxyModel->getPlaceHolderImage();
     }
     $imageTypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png');
     if (in_array($image['mime_type'], $imageTypes)) {
         $this->_response->setHeader('Content-type', $image['mime_type'], true);
         $this->_setDownloadFileName($image['file_name'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->_setDownloadFileName($image['file_name']);
     }
     if (!$error) {
         $this->_response->setHeader('ETag', '"' . $image['fetch_date'] . '"', true);
     }
     if ($image['file_size']) {
         $this->_response->setHeader('Content-Length', $image['file_size'], true);
     }
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     if ($error) {
         $this->_response->setHeader('X-Proxy-Error', $error);
     }
     $this->_response->sendHeaders();
     $imageData = new XenForo_FileOutput($image['file_path']);
     $imageData->output();
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:63,代码来源:ProxyOutput.php

示例3: _challengeClient

 /**
  * Challenge Client
  *
  * Sets a 401 Unauthorized response code, and creates the
  * appropriate Authenticate header(s) to prompt for credentials.
  *
  * @return Zend_Auth_Result Always returns a non-identity Auth result
  */
 protected function _challengeClient()
 {
     $this->_response->setHttpResponseCode(401);
     // Send a challenge in each acceptable authentication scheme
     foreach ($this->_schemes as $scheme => $callback) {
         $this->_response->setHeader('WWW-Authenticate', $scheme);
     }
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Invalid or absent credentials; challenging client'));
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:17,代码来源:M2m.php

示例4: testPostDispatchDoesNothingOnRedirect

 public function testPostDispatchDoesNothingOnRedirect()
 {
     $this->request->setModuleName('bar')->setControllerName('index')->setActionName('test')->setDispatched(true);
     $this->response->setHttpResponseCode(302);
     $controller = new Bar_IndexController($this->request, $this->response, array());
     $this->helper->setActionController($controller);
     $this->helper->postDispatch();
     $content = $this->response->getBody();
     $this->assertNotContains('Rendered index/test.phtml in bar module', $content);
     $this->assertTrue(empty($content));
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:11,代码来源:ViewRendererTest.php

示例5: _challengeClient

 /**
  * Challenge Client
  *
  * Sets a 401 or 407 Unauthorized response code, and creates the
  * appropriate Authenticate header(s) to prompt for credentials.
  *
  * @return Zend_Auth_Result Always returns a non-identity Auth result
  */
 protected function _challengeClient()
 {
     if ($this->_imaProxy) {
         $statusCode = 407;
         $headerName = 'Proxy-Authenticate';
     } else {
         $statusCode = 401;
         $headerName = 'WWW-Authenticate';
     }
     $this->_response->setHttpResponseCode($statusCode);
     $this->_response->setHeader($headerName, $this->_getAuthHeader());
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Invalid or absent credentials; challenging client'));
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:21,代码来源:Abstract.php

示例6: _error

 protected function _error($message = null, $statusCode = self::REST_STATUS_BAD_REQUEST)
 {
     if (is_numeric($statusCode)) {
         $statusCode = intval($statusCode);
     }
     $this->_response->clearAllHeaders()->clearBody();
     $this->_response->setHttpResponseCode(intval($statusCode))->setHeader('Content-Type', 'application/json', true);
     if (!empty($message)) {
         $this->_response->setBody(json_encode($message));
     }
     $this->_response->sendResponse();
     exit;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:13,代码来源:Abstract.php

示例7: authenticate

 /**
  * Enter description here...
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     if ('' == ($authHeader = $this->_request->getServer("HTTP_X_WSSE"))) {
         $this->_response->setHttpResponseCode(401, 'Unauthorized', true);
         $this->_response->setHeader('WWW-Authenticate', 'WSSE realm="' . $this->_realm . '", profile="UsernameToken"');
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, array(), array('Missing WSSE Header'));
     }
     $headerParts = $this->parseWsseHeader($authHeader);
     $passwordDigest = $this->createPasswordDigest($headerParts['nonce'], $headerParts['created'], $this->_credential);
     if ($passwordDigest == $headerParts['digest'] && $this->_identity == $headerParts['username']) {
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_identity);
     }
     $this->_response->setHttpResponseCode(401, 'Unauthorized', true);
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('Unauthorized'));
 }
开发者ID:johannilsson,项目名称:yag,代码行数:21,代码来源:Wsse.php

示例8: __construct

 public function __construct($msg = '', $code = 0, Exception $previous = null)
 {
     // just pass ahead if it was throw from the CLI
     if (php_sapi_name() == "cli") {
         return parent::__construct($msg, (int) $code, $previous);
     } else {
         parent::__construct($msg, (int) $code, $previous);
         $response = new Zend_Controller_Response_Http();
         $response->setHttpResponseCode(500);
         ob_get_clean();
         ob_start();
         require APPLICATION_PATH . "/layout/scripts/exception.phtml";
         $outputBuffer = ob_get_clean();
         $response->setBody($outputBuffer);
         $response->sendResponse();
         trigger_error($msg, E_USER_ERROR);
         exit;
     }
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:19,代码来源:Exception.php

示例9: getHttpHost

 /**
  * Retrieve HTTP HOST
  *
  * @param bool $trimPort
  * @return string
  */
 public function getHttpHost($trimPort = true)
 {
     if (!isset($_SERVER['HTTP_HOST'])) {
         return false;
     }
     $host = $_SERVER['HTTP_HOST'];
     if ($trimPort) {
         $hostParts = explode(':', $_SERVER['HTTP_HOST']);
         $host = $hostParts[0];
     }
     if (strpos($host, ',') !== false || strpos($host, ';') !== false) {
         $response = new Zend_Controller_Response_Http();
         $response->setHttpResponseCode(400)->sendHeaders();
         exit;
     }
     return $host;
 }
开发者ID:lightyoruichi,项目名称:Magento-Pre-Patched-Files,代码行数:23,代码来源:Http.php

示例10: run

 public function run(Zend_Controller_Response_Abstract $response = null)
 {
     $args = array($this);
     $this->runCallback(self::CB_BEFORE_RUN, $args);
     if ($response === null) {
         $response = new Zend_Controller_Response_Http();
     }
     $this->response = $response;
     $action = $this->getCurrentAction();
     $this->request->setActionName($action);
     ob_start();
     $this->actionRun($action);
     if ($this->response->isRedirect() && $this->completeRequest->isXmlHttpRequest()) {
         $url = null;
         foreach ($response->getHeaders() as $header) {
             if ($header['name'] == 'Location') {
                 $url = $header['value'];
             }
         }
         $code = $response->getHttpResponseCode();
         // change request to ajax response
         $response->clearAllHeaders();
         $response->clearBody();
         $response->setHttpResponseCode(200);
         $response->setHeader("Content-Type", "application/json; charset=UTF-8", true);
         $response->setBody(Am_Controller::getJson(array('ngrid-redirect' => $url, 'status' => $code)));
         //throw new Am_Exception_Redirect($url);
     } else {
         $response->appendBody(ob_get_clean());
     }
     unset($this->response);
     return $response;
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:33,代码来源:ReadOnly.php

示例11: _getFullPageUrl

 /**
  * Return current page base url
  *
  * @return string
  */
 protected function _getFullPageUrl()
 {
     $uri = false;
     /**
      * Define server HTTP HOST
      */
     if (isset($_SERVER['HTTP_HOST'])) {
         if (strpos($_SERVER['HTTP_HOST'], ',') !== false || strpos($_SERVER['HTTP_HOST'], ';') !== false) {
             $response = new Zend_Controller_Response_Http();
             $response->setHttpResponseCode(400)->sendHeaders();
             exit;
         }
         $uri = $_SERVER['HTTP_HOST'];
     } elseif (isset($_SERVER['SERVER_NAME'])) {
         $uri = $_SERVER['SERVER_NAME'];
     }
     /**
      * Define request URI
      */
     if ($uri) {
         if (isset($_SERVER['REQUEST_URI'])) {
             $uri .= $_SERVER['REQUEST_URI'];
         } elseif (!empty($_SERVER['IIS_WasUrlRewritten']) && !empty($_SERVER['UNENCODED_URL'])) {
             $uri .= $_SERVER['UNENCODED_URL'];
         } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
             $uri .= $_SERVER['ORIG_PATH_INFO'];
             if (!empty($_SERVER['QUERY_STRING'])) {
                 $uri .= $_SERVER['QUERY_STRING'];
             }
         }
     }
     return $uri;
 }
开发者ID:QiuLihua83,项目名称:magento-ee,代码行数:38,代码来源:Processor.php

示例12: _sendResponse

 protected function _sendResponse($httpCode, $code, $message)
 {
     // TODO Why is sometimes sending response twice??? :S
     if (self::$responseSent) {
         return;
     }
     if (!($response = Zend_Controller_Front::getInstance()->getResponse())) {
         $response = new Zend_Controller_Response_Http();
     }
     $response->setHttpResponseCode($httpCode);
     if (!$response->getBody()) {
         $body = array('code' => $code, 'message' => $message);
         $response->setBody(Zend_Json::encode($body));
     }
     if ($response->canSendHeaders()) {
         $response->clearHeaders();
         $response->setHeader('Content-Type', 'application/json');
         $response->sendResponse();
         self::$responseSent = true;
     }
     exit;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:22,代码来源:Bootstrap.php

示例13: microtime

<?php

$startTime = microtime(true);
$fileDir = dirname(__FILE__);
require $fileDir . '/library/XenForo/Autoloader.php';
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$deps = new XenForo_Dependencies_Public();
$deps->preLoadData();
$response = new Zend_Controller_Response_Http();
$processor = new XenForo_UserUpgradeProcessor_Paymentwall();
$processor->initCallbackHandling(new Zend_Controller_Request_Http());
$logExtra = array();
try {
    if (!($processor->validateRequest() && $processor->validatePreConditions())) {
        throw new Exception($processor->getLogMessage(), 500);
    }
    list($logType, $logMessage) = $processor->processTransaction();
} catch (Exception $e) {
    $response->setHttpResponseCode($e->getCode());
    XenForo_Error::logException($e);
    $logType = 'error';
    $logMessage = 'Exception: ' . $e->getMessage();
    $logExtra['_e'] = $e;
}
$processor->log($logType, $logMessage, $logExtra);
$response->setBody(htmlspecialchars($logMessage));
$response->sendResponse();
开发者ID:paymentwall,项目名称:module-xenforo,代码行数:29,代码来源:paymentwall.php

示例14: sendPackage

 /**
  * @see AM_Handler_Export_Storage_Interface::sendPackage()
  * @throws AM_Handler_Export_Storage_Exception
  */
 public function sendPackage()
 {
     $sFilePath = $this->_buildPackagePath() . DIRECTORY_SEPARATOR . $this->getPackage()->getPackageName();
     $sFileName = $this->getPackage()->getPackageDownloadName();
     if (!file_exists($sFilePath)) {
         throw new AM_Handler_Export_Storage_Exception(sprintf('File "%s" not found', $sFilePath));
     }
     $oResponse = new Zend_Controller_Response_Http();
     $oResponse->setHttpResponseCode(200);
     $oRequest = new Zend_Controller_Request_Http();
     $iFileSize = filesize($sFilePath);
     $sFileMtime = @gmdate("D, d M Y H:i:s", @filemtime($sFilePath)) . " GMT";
     $rFile = @fopen($sFilePath, 'rb');
     $sRange = $oRequest->get('HTTP_RANGE');
     //Trying to resume download according to the HTTP_RANGE header
     if (preg_match('/bytes=(\\d+)-(\\d*)/i', $sRange, $matches)) {
         $sRange = $matches[1];
     } else {
         $sRange = false;
     }
     if ($sRange) {
         fseek($rFile, $sRange);
         $oResponse->setHttpResponseCode(206);
         $oResponse->setHeader('Content-Range', sprintf('bytes %d-%d/%d', $sRange, $iFileSize - 1, $iFileSize));
     }
     $oResponse->setHeader('Content-Disposition', 'attachment; filename=' . $sFileName)->setHeader('Content-Length', $iFileSize - $sRange)->setHeader('Content-Type', 'application/octet-stream')->setHeader('Accept-Ranges', 'bytes')->setHeader('Last-Modified', $sFileMtime);
     while (!feof($rFile)) {
         $sBuffer = fread($rFile, 2048);
         $oResponse->appendBody($sBuffer);
     }
     fclose($rFile);
     $oResponse->sendResponse();
 }
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:37,代码来源:Local.php

示例15: setResponse

 /**
  * Set response object
  *
  * @param Zend_Controller_Response_Http $response
  * @return Mage_Oauth_Model_Server
  */
 public function setResponse(Zend_Controller_Response_Http $response)
 {
     $this->_response = $response;
     $this->_response->setHeader(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED, true);
     $this->_response->setHttpResponseCode(self::HTTP_OK);
     return $this;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:13,代码来源:Server.php


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