mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #6312 from dhensby/pulls/3.4/httpresponse-phpdoc
DOCS Update PHPDoc for SS_HTTPResponse
This commit is contained in:
commit
8a0383e5a9
@ -66,12 +66,12 @@ class SS_HTTPResponse {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $statusCode = 200;
|
protected $statusCode = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var String
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $statusDescription = "OK";
|
protected $statusDescription = "OK";
|
||||||
|
|
||||||
@ -93,9 +93,9 @@ class SS_HTTPResponse {
|
|||||||
/**
|
/**
|
||||||
* Create a new HTTP response
|
* Create a new HTTP response
|
||||||
*
|
*
|
||||||
* @param $body The body of the response
|
* @param string $body The body of the response
|
||||||
* @param $statusCode The numeric status code - 200, 404, etc
|
* @param int $statusCode The numeric status code - 200, 404, etc
|
||||||
* @param $statusDescription The text to be given alongside the status code.
|
* @param string $statusDescription The text to be given alongside the status code.
|
||||||
* See {@link setStatusCode()} for more information.
|
* See {@link setStatusCode()} for more information.
|
||||||
*/
|
*/
|
||||||
public function __construct($body = null, $statusCode = null, $statusDescription = null) {
|
public function __construct($body = null, $statusCode = null, $statusDescription = null) {
|
||||||
@ -104,12 +104,12 @@ class SS_HTTPResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $code
|
* @param int $code
|
||||||
* @param String $description Optional. See {@link setStatusDescription()}.
|
* @param string $description Optional. See {@link setStatusDescription()}.
|
||||||
* No newlines are allowed in the description.
|
* No newlines are allowed in the description.
|
||||||
* If omitted, will default to the standard HTTP description
|
* If omitted, will default to the standard HTTP description
|
||||||
* for the given $code value (see {@link $status_codes}).
|
* for the given $code value (see {@link $status_codes}).
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setStatusCode($code, $description = null) {
|
public function setStatusCode($code, $description = null) {
|
||||||
if(isset(self::$status_codes[$code])) $this->statusCode = $code;
|
if(isset(self::$status_codes[$code])) $this->statusCode = $code;
|
||||||
@ -124,8 +124,8 @@ class SS_HTTPResponse {
|
|||||||
* The text to be given alongside the status code ("reason phrase").
|
* The text to be given alongside the status code ("reason phrase").
|
||||||
* Caution: Will be overwritten by {@link setStatusCode()}.
|
* Caution: Will be overwritten by {@link setStatusCode()}.
|
||||||
*
|
*
|
||||||
* @param String $description
|
* @param string $description
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setStatusDescription($description) {
|
public function setStatusDescription($description) {
|
||||||
$this->statusDescription = $description;
|
$this->statusDescription = $description;
|
||||||
@ -133,7 +133,7 @@ class SS_HTTPResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getStatusCode() {
|
public function getStatusCode() {
|
||||||
return $this->statusCode;
|
return $this->statusCode;
|
||||||
@ -157,7 +157,7 @@ class SS_HTTPResponse {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $body
|
* @param string $body
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setBody($body) {
|
public function setBody($body) {
|
||||||
$this->body = $body ? (string) $body : $body; // Don't type-cast false-ish values, eg null is null not ''
|
$this->body = $body ? (string) $body : $body; // Don't type-cast false-ish values, eg null is null not ''
|
||||||
@ -176,7 +176,7 @@ class SS_HTTPResponse {
|
|||||||
*
|
*
|
||||||
* @param string $header Example: "Content-Type"
|
* @param string $header Example: "Content-Type"
|
||||||
* @param string $value Example: "text/xml"
|
* @param string $value Example: "text/xml"
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function addHeader($header, $value) {
|
public function addHeader($header, $value) {
|
||||||
$this->headers[$header] = $value;
|
$this->headers[$header] = $value;
|
||||||
@ -206,7 +206,7 @@ class SS_HTTPResponse {
|
|||||||
* e.g. "Content-Type".
|
* e.g. "Content-Type".
|
||||||
*
|
*
|
||||||
* @param string $header
|
* @param string $header
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function removeHeader($header) {
|
public function removeHeader($header) {
|
||||||
if(isset($this->headers[$header])) unset($this->headers[$header]);
|
if(isset($this->headers[$header])) unset($this->headers[$header]);
|
||||||
@ -216,7 +216,7 @@ class SS_HTTPResponse {
|
|||||||
/**
|
/**
|
||||||
* @param string $dest
|
* @param string $dest
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @return SS_HTTPRequest $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function redirect($dest, $code=302) {
|
public function redirect($dest, $code=302) {
|
||||||
if(!in_array($code, self::$redirect_codes)) $code = 302;
|
if(!in_array($code, self::$redirect_codes)) $code = 302;
|
||||||
@ -310,12 +310,17 @@ EOT
|
|||||||
*/
|
*/
|
||||||
class SS_HTTPResponse_Exception extends Exception {
|
class SS_HTTPResponse_Exception extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SS_HTTPResponse
|
||||||
|
*/
|
||||||
protected $response;
|
protected $response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|SS_HTTPResponse body Either the plaintext content of the error message, or an SS_HTTPResponse
|
* @param string|SS_HTTPResponse body Either the plaintext content of the error message, or an SS_HTTPResponse
|
||||||
* object representing it. In either case, the $statusCode and
|
* object representing it. In either case, the $statusCode and
|
||||||
* $statusDescription will be the HTTP status of the resulting response.
|
* $statusDescription will be the HTTP status of the resulting response.
|
||||||
|
* @param int $statusCode
|
||||||
|
* @param string $statusDescription
|
||||||
* @see SS_HTTPResponse::__construct();
|
* @see SS_HTTPResponse::__construct();
|
||||||
*/
|
*/
|
||||||
public function __construct($body = null, $statusCode = null, $statusDescription = null) {
|
public function __construct($body = null, $statusCode = null, $statusDescription = null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user