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


PHP SS_HTTPResponse::getStatusCode方法代码示例

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


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

示例1: postRequest

 public function postRequest(\SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model)
 {
     if ($this->convertUrls && $response && $response->getStatusCode() == 200) {
         // only convert if we have an HTML content type response
         $body = $response->getBody();
         // find urls inserted in content
         if (strpos($body, 'cdnfileid') > 0 && preg_match_all('/data-cdnfileid="(\\d+)"/', $body, $matches)) {
             $files = CdnImage::get()->filter('ID', $matches[1]);
             $fileIds = array();
             foreach ($files as $file) {
                 $url = $file->getUrl();
                 $filename = $file->Filename;
                 $body = str_replace("src=\"{$filename}\"", "src=\"{$url}\"", $body);
                 $fileIds[] = $file->ID;
             }
             $assets = ContentServiceAsset::get()->filter('SourceID', $matches[1]);
             foreach ($assets as $asset) {
                 $url = $asset->getUrl();
                 $filename = $asset->Filename;
                 // note the extra forward slash here, image_cached inserts it
                 $body = str_replace("src=\"/{$filename}\"", "src=\"{$url}\"", $body);
             }
             $response->setBody($body);
         }
     }
 }
开发者ID:stephenmcm,项目名称:silverstripe-cdncontent,代码行数:26,代码来源:AssetUrlConversionFilter.php

示例2: postRequest

 /**
  * Filter executed AFTER a request
  *
  * @param SS_HTTPRequest $request Request container object
  * @param SS_HTTPResponse $response Response output object
  * @param DataModel $model Current DataModel
  * @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     $code = $response->getStatusCode();
     $error_page_path = Director::baseFolder() . "/errors_pages/ui/{$code}/index.html";
     if (!$request->isAjax() && file_exists($error_page_path)) {
         //clean buffer
         ob_clean();
         $page_file = fopen($error_page_path, "r") or die("Unable to open file!");
         $body = fread($page_file, filesize($error_page_path));
         fclose($page_file);
         // set content type
         $response->addHeader('Content-Type', 'text/html');
         $response->setBody($body);
         $response->setStatusCode(200);
         return true;
     }
     return true;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:26,代码来源:HttpErrorRequestFilter.php

示例3: wasRedirected

 /**
  * Returns true if the last response was a 3xx redirection
  *
  * @return bool
  */
 public function wasRedirected()
 {
     $code = $this->lastResponse->getStatusCode();
     return $code >= 300 && $code < 400;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:10,代码来源:TestSession.php

示例4: assertResponseEquals

 /**
  * Assert that a response matches the given parameters
  *
  * @param int $code HTTP code
  * @param string $body Body expected for 200 responses
  * @param SS_HTTPResponse $response
  */
 protected function assertResponseEquals($code, $body, SS_HTTPResponse $response)
 {
     $this->assertEquals($code, $response->getStatusCode());
     if ($code === 200) {
         $this->assertFalse($response->isError());
         $this->assertEquals($body, $response->getBody());
         $this->assertEquals('text/plain', $response->getHeader('Content-Type'));
     } else {
         $this->assertTrue($response->isError());
     }
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:18,代码来源:ProtectedFileControllerTest.php

示例5: postRequest

 /**
  *	Attempt to redirect towards the highest priority link mapping that may have been defined.
  *
  *	@URLparameter direct <{BYPASS_LINK_MAPPINGS}> boolean
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     // Bypass the request filter when requesting specific director rules such as "/admin" or "/dev".
     $requestURL = $request->getURL();
     $configuration = Config::inst();
     foreach ($configuration->get('Director', 'rules') as $segment => $controller) {
         // Retrieve the specific director rules.
         if (($position = strpos($segment, '$')) !== false) {
             $segment = rtrim(substr($segment, 0, $position), '/');
         }
         // Determine if the current request matches a specific director rule.
         if ($segment && strpos($requestURL, $segment) === 0) {
             // Continue processing the response.
             return true;
         }
     }
     // Bypass the request filter when using the direct GET parameter.
     if ($request->getVar('direct')) {
         // Continue processing the response.
         return true;
     }
     // Determine the default automated URL handling response status.
     $status = $response->getStatusCode();
     $success = $status >= 200 && $status < 300;
     $error = $status === 404;
     // Either hook into a page not found, or when enforced, replace the default automated URL handling.
     $enforce = $configuration->get('MisdirectionRequestFilter', 'enforce_misdirection');
     $replace = $configuration->get('MisdirectionRequestFilter', 'replace_default');
     if (($error || $enforce || $replace) && ($map = $this->service->getMappingByRequest($request))) {
         // Update the response code where appropriate.
         $responseCode = $map->ResponseCode;
         if ($responseCode == 0) {
             $responseCode = 303;
         } else {
             if ($responseCode == 301 && $map->ForwardPOSTRequest) {
                 $responseCode = 308;
             } else {
                 if ($responseCode == 303 && $map->ForwardPOSTRequest) {
                     $responseCode = 307;
                 }
             }
         }
         // Update the response using the link mapping redirection.
         $response->redirect($map->getLink(), $responseCode);
     } else {
         if ($error && ($fallback = $this->service->determineFallback($requestURL))) {
             // Update the response code where appropriate.
             $responseCode = $fallback['code'];
             if ($responseCode === 0) {
                 $responseCode = 303;
             }
             // Update the response using the fallback, enforcing no further redirection.
             $response->redirect(HTTP::setGetVar('direct', true, Controller::join_links(Director::absoluteBaseURL(), $fallback['link'])), $responseCode);
         } else {
             if (!$error && !$success && $replace) {
                 $response->setStatusCode(404);
                 // Retrieve the appropriate page not found response.
                 ClassInfo::exists('SiteTree') && ($page = ErrorPage::response_for(404)) ? $response->setBody($page->getBody()) : $response->setBody('No URL was matched!');
             }
         }
     }
     // Continue processing the response.
     return true;
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-misdirection,代码行数:69,代码来源:MisdirectionRequestFilter.php

示例6: getErrorMessage

	/**
	 * @param SS_HTTPResponse $response
	 * @return string XML string containing the HTTP error message
	 */
	protected function getErrorMessage($response) {
		return "<error type=\"authentication\" code=\"" . $response->getStatusCode() . "\">" . $response->getStatusDescription() . "</error>";
	}
开发者ID:redema,项目名称:sapphire,代码行数:7,代码来源:SOAPModelAccess.php

示例7: remove

 /**
  * Action to handle removing a single file from the db relation
  * 
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function remove(SS_HTTPRequest $request)
 {
     // Check form field state
     if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
         return $this->httpError(403);
     }
     // Protect against CSRF on destructive action
     $token = $this->parent->getForm()->getSecurityToken();
     if (!$token->checkRequest($request)) {
         return $this->httpError(400);
     }
     $response = new SS_HTTPResponse();
     $response->setStatusCode(500);
     $fieldName = $this->parent->getName();
     $record = $this->parent->getRecord();
     $id = $this->getItem()->ID;
     if ($id && $record && $record->exists()) {
         if (($record->has_many($fieldName) || $record->many_many($fieldName)) && ($file = $record->{$fieldName}()->byID($id))) {
             $record->{$fieldName}()->remove($file);
             $response->setStatusCode(200);
         } elseif ($record->has_one($fieldName) && $record->{$fieldName . 'ID'} == $id) {
             $record->{$fieldName . 'ID'} = 0;
             $record->write();
             $response->setStatusCode(200);
         }
     }
     if ($response->getStatusCode() != 200) {
         $response->setStatusDescription(_t('UploadField.REMOVEERROR', 'Error removing file'));
     }
     return $response;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:37,代码来源:UploadField.php

示例8: setResponse

 public function setResponse(SS_HTTPResponse $response)
 {
     $body = json_encode(array('data' => array('status_code' => $response->getStatusCode(), 'message' => $response->getBody())));
     $this->response = new JsonDataResponse($body, $response->getStatusCode(), $response->getStatusDescription());
 }
开发者ID:tom-alexander,项目名称:silverstripe-api,代码行数:5,代码来源:JsonDataResponse.php


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