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


PHP Zend_Http_Response::responseCodeAsText方法代码示例

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


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

示例1: errorAction

 /**
  * Handle all API errors.
  */
 public function errorAction()
 {
     $data = array();
     $exception = $this->_getParam('error_handler')->exception;
     // Add code and message to response.
     $code = $exception->getCode();
     if (!$code) {
         $code = self::DEFAULT_HTTP_RESPONSE_CODE;
     }
     $message = $exception->getMessage();
     if (!$message) {
         $message = Zend_Http_Response::responseCodeAsText($code);
     }
     $data['message'] = $message;
     // Add errors to response.
     if ($exception instanceof Omeka_Controller_Exception_Api) {
         if ($errors = $exception->getErrors()) {
             $data['errors'] = $errors;
         }
     }
     try {
         $this->getResponse()->setHttpResponseCode($code);
     } catch (Zend_Controller_Exception $e) {
         // The response code was invalid. Set the default.
         $this->getResponse()->setHttpResponseCode(self::DEFAULT_HTTP_RESPONSE_CODE);
     }
     $this->_helper->json($data);
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:31,代码来源:ErrorController.php

示例2: _doRequest

 /**
  * Make a HTTP request.
  * @param string $method
  * @param array $getParameters
  * @param array $postParameters
  * @throws Insulin_Service_Rest_ConnectionFailedException
  * @throws Insulin_Service_Rest_HttpErrorException
  */
 protected function _doRequest($method, array $getParameters = null, array $postParameters = null)
 {
     $link = $this->getLink();
     if (!empty($postParameters)) {
         $link->setParameterPost($postParameters);
     }
     if (!empty($getParameters)) {
         $link->setParameterGet($getParameters);
     }
     $link->setUri($this->_endpoint);
     $link->setMethod($method);
     require_once 'Zend/Http/Exception.php';
     try {
         $response = $link->request();
     } catch (Zend_Http_Exception $e) {
         require_once 'Insulin/Service/Rest/ConnectionFailedException.php';
         throw new Insulin_Service_Rest_ConnectionFailedException();
     }
     if ($response->isError()) {
         require_once 'Insulin/Service/Rest/HttpErrorException.php';
         // extract error code from response
         $code = Zend_Http_Response::extractCode($response);
         // extract standard error message from response
         $msg = Zend_Http_Response::responseCodeAsText($code);
         throw new Insulin_Service_Rest_HttpErrorException($code, $msg);
     }
     return $response;
 }
开发者ID:rnogueira,项目名称:insulin-lib,代码行数:36,代码来源:Client.php

示例3: __construct

 public function __construct($statusCode, $isFlexClient = false)
 {
     $this->_isFlexClient = $isFlexClient;
     $this->_realStatusCode = $statusCode;
     if ($this->_isFlexClient == true) {
         $this->_statusCode = 200;
         $this->_statusMessage = Zend_Http_Response::responseCodeAsText($this->_realStatusCode);
         parent::__construct(200, $_SERVER);
         header("HTTP/1.1 200 OK");
     } else {
         $this->_statusCode = $statusCode;
         $this->_statusMessage = Zend_Http_Response::responseCodeAsText($statusCode);
         parent::__construct($statusCode, $_SERVER);
         header("HTTP/1.1 {$statusCode} " . $this->_statusMessage);
     }
 }
开发者ID:rockholla,项目名称:zend-framework-ext,代码行数:16,代码来源:HttpResponse.php

示例4: testUnknownCode

 public function testUnknownCode()
 {
     $response_str = $this->readResponse('response_unknown');
     $response = Zend_Http_Response::fromString($response_str);
     // Check that dynamically the message is parsed
     $this->assertEquals(550, $response->getStatus(), 'Status is expected to be a non-standard 550');
     $this->assertEquals('Printer On Fire', $response->getMessage(), 'Message is expected to be extracted');
     // Check that statically, an Unknown string is returned for the 550 code
     $this->assertEquals('Unknown', Zend_Http_Response::responseCodeAsText($response_str));
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:10,代码来源:ResponseTest.php

示例5: fetch

 /** Send a request to the server.
  *
  * @param string $method
  * @param string $path
  * @param array  $params
  *
  * @return string server response.
  */
 public function fetch($method, $path, array $params = array())
 {
     $key = $this->_genContentKey($path, $params);
     if (isset($this->_content[$method][$key])) {
         list($content, $status) = $this->_content[$method][$key];
     } elseif (isset($this->_content[self::METHOD_ANY][$key])) {
         list($content, $status) = $this->_content[self::METHOD_ANY][$key];
     } else {
         $status = self::STATUS_NOT_FOUND;
         $content = Zend_Http_Response::responseCodeAsText(self::STATUS_NOT_FOUND);
     }
     $this->_requests[] = $key;
     return new JsonApi_Http_Response($this->getUri($path, $params, $method), $status, $content);
 }
开发者ID:JWT-OSS,项目名称:sfJwtJsonApiPlugin,代码行数:22,代码来源:Mock.class.php

示例6: responseCodeAsText

 /**
  * Maps HTTP status code to correct HTTP response text.
  */
 public function responseCodeAsText()
 {
     require_once 'Zend/Http/Response.php';
     return Zend_Http_Response::responseCodeAsText($this->code);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:bootstrap.php

示例7: _apiRequest

 /**
  * Applies the search filter and makes the actual API request
  *
  * @param array $searchFilter
  * @return string
  */
 private function _apiRequest(array $searchFilter)
 {
     $this->_setSearchFilter($searchFilter);
     $serviceUri = $this->_apiEndpoint . ".{$this->_responseFormat}";
     $client = new Zend_Http_Client($serviceUri);
     $client->setParameterGet(array('key' => $this->_apiKey));
     foreach ($this->_searchFilter as $key => $value) {
         if ($key === 'url') {
             $key = 'q';
         }
         $client->setParameterGet(array($key => $value));
     }
     $response = $client->request();
     if (403 === Zend_Http_Response::extractCode($response)) {
         $codeAsText = strtolower(Zend_Http_Response::responseCodeAsText(403));
         throw new Exception("Access to Backtweets API {$codeAsText}, check used API key");
     }
     return $response->getBody();
 }
开发者ID:raphaelstolt,项目名称:backtweets-api-client,代码行数:25,代码来源:Backtweets.php

示例8: failureDescription

 /** Appends relevant error message information to a failed status check.
  *
  * @param Test_Browser  $browser
  *
  * @return string
  */
 protected function failureDescription($browser)
 {
     $code = $browser->getResponse()->getStatusCode();
     /* See if there's an error we can report. */
     if (!($error = (string) $browser->getError())) {
         $error = Zend_Http_Response::responseCodeAsText($code);
     }
     return sprintf(self::MESSAGE, $this->toString(), $code, $error);
 }
开发者ID:todofixthis,项目名称:sfJwtPhpUnitPlugin,代码行数:15,代码来源:StatusCodeEquals.class.php

示例9: getStatus

 /** Accessor for $_status.
  *
  * @param bool $asString
  *
  * @return int
  */
 public function getStatus($asString = false)
 {
     return $asString ? Zend_Http_Response::responseCodeAsText($this->_status) : $this->_status;
 }
开发者ID:JWT-OSS,项目名称:sfJwtJsonApiPlugin,代码行数:10,代码来源:Response.class.php

示例10: parseRawResponse

 /**
  * Extract the API response data from the given HTTP response object.
  *
  * @param Zend_Http_Response $response
  *
  * @return $this
  */
 protected function parseRawResponse(Zend_Http_Response $response)
 {
     if ($response->isSuccessful()) {
         $content = $response->getBody();
         if (strlen($content) > 0) {
             try {
                 $xml = simplexml_load_string($response->getBody());
             } catch (Exception $e) {
                 // Failed to parse XML
                 $this->successful = false;
                 $this->setMessage("Failed to parse a response from Klevu.");
                 Mage::helper('klevu_search')->log(Zend_Log::ERR, sprintf("Failed to parse XML response: %s", $e->getMessage()));
                 return $this;
             }
             $this->xml = $xml;
             $this->successful = true;
         } else {
             // Response contains no content
             $this->successful = false;
             $this->setMessage('Failed to parse a response from Klevu.');
             Mage::helper('klevu_search')->log(Zend_Log::ERR, "API response content is empty.");
         }
     } else {
         // Unsuccessful HTTP response
         $this->successful = false;
         switch ($response->getStatus()) {
             case 403:
                 $message = "Incorrect API keys.";
                 break;
             case 500:
                 $message = "API server error.";
                 break;
             case 503:
                 $message = "API server unavailable.";
                 break;
             default:
                 $message = "Unexpected error.";
         }
         $this->setMessage(sprintf("Failed to connect to Klevu: %s", $message));
         Mage::helper('klevu_search')->log(Zend_Log::ERR, sprintf("Unsuccessful HTTP response: %s %s", $response->getStatus(), $response->responseCodeAsText($response->getStatus())));
     }
     return $this;
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:50,代码来源:Response.php

示例11: __construct

 public function __construct($responseCode, $message = null)
 {
     parent::__construct(null !== $message ? $message : Zend_Http_Response::responseCodeAsText($responseCode), self::ERROR_CODE_BASE + (int) $responseCode);
     $this->_responseCode = $responseCode;
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:5,代码来源:Exception.php

示例12: setHeaderStatus

 /**
  * Send the $exception's code or $code as the formal HTTP status of the response.
  *
  * @param  integer    $code  suggested HTTP response code, if exception fails to provide one
  * @param  Exception  $exception   OPTIONAL HTTP status code
  * @return string   status code and description
  */
 private static function setHeaderStatus($code, Exception $exception = null)
 {
     switch ($code) {
         case 404:
             $status = '404 Not Found';
             break;
         case 500:
             $status = '500 Internal Server Error';
             break;
         default:
             require_once 'Zend/Http/Response.php';
             $status = $code . ' ' . Zend_Http_Response::responseCodeAsText($code);
     }
     if ('cgi' !== substr(php_sapi_name(), 0, 3) && !empty($_SERVER['SERVER_PROTOCOL'])) {
         header($_SERVER['SERVER_PROTOCOL'] . ' ' . $status, true);
     } else {
         header('Status: ' . $status, true);
     }
     return $status;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:27,代码来源:bootstrap.php


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