PHP Класс ManaPHP\Http\Response

Наследование: extends ManaPHP\Component, implements ManaPHP\Http\ResponseInterface
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_content string
$_file string
$_headers array
$_sent boolean

Открытые методы

Метод Описание
appendContent ( string $content ) : static Appends a string to the HTTP response body
getContent ( ) : string Gets the HTTP response body
getHeaders ( ) : array
isSent ( ) : boolean Check if the response is already sent
redirect ( string | array $location, boolean $temporarily = true ) : static Redirect by HTTP to another action or URL Using a string redirect (internal/external) $response->redirect("posts/index"); $response->redirect("http://www.google.com"); $response->redirect("http://www.example.com/new-location", false);
send ( ) : static Prints out HTTP response to the client
sendHeaders ( ) : static Sends headers to the client
setAttachment ( string $attachmentName ) : static
setContent ( string $content ) : static Sets HTTP response body $response->setContent("

Hello!

");
setContentType ( string $contentType, string $charset = null ) : static Sets the response content-type mime, optionally the charset $response->setContentType('application/pdf'); $response->setContentType('text/plain', 'UTF-8');
setCsvContent ( array $rows, string $attachmentName, array | string $columns = null ) : static
setEtag ( string $etag ) : static Set a custom ETag $response->setEtag(md5(time()));
setExpires ( integer $timestamp ) : static Sets a Expires header to use HTTP cache $this->response->setExpires(new DateTime());
setFileToSend ( string $file, string $attachmentName = null ) : static Sets an attached file to be sent at the end of the request
setHeader ( string $name, string $value ) : static Overwrites a header in the response $response->setHeader("Content-Type", "text/plain");
setJsonContent ( array $content, integer $jsonOptions = null ) : static Sets HTTP response body. The parameter is automatically converted to JSON $response->setJsonContent(array("status" => "OK")); $response->setJsonContent(array("status" => "OK"), JSON_NUMERIC_CHECK);
setNotModified ( ) : static Sets a Not-Modified response
setRawHeader ( string $header ) : static Send a raw header to the response $response->setRawHeader("HTTP/1.1 404 Not Found");
setStatusCode ( integer $code, string $message ) : static Sets the HTTP response code $response->setStatusCode(404, "Not Found");

Описание методов

appendContent() публичный Метод

Appends a string to the HTTP response body
public appendContent ( string $content ) : static
$content string
Результат static

getContent() публичный Метод

Gets the HTTP response body
public getContent ( ) : string
Результат string

getHeaders() публичный Метод

public getHeaders ( ) : array
Результат array

isSent() публичный Метод

Check if the response is already sent
public isSent ( ) : boolean
Результат boolean

redirect() публичный Метод

Redirect by HTTP to another action or URL Using a string redirect (internal/external) $response->redirect("posts/index"); $response->redirect("http://www.google.com"); $response->redirect("http://www.example.com/new-location", false);
public redirect ( string | array $location, boolean $temporarily = true ) : static
$location string | array
$temporarily boolean
Результат static

send() публичный Метод

Prints out HTTP response to the client
public send ( ) : static
Результат static

sendHeaders() публичный Метод

Sends headers to the client
public sendHeaders ( ) : static
Результат static

setAttachment() публичный Метод

public setAttachment ( string $attachmentName ) : static
$attachmentName string
Результат static

setContent() публичный Метод

Sets HTTP response body $response->setContent("

Hello!

");
public setContent ( string $content ) : static
$content string
Результат static

setContentType() публичный Метод

Sets the response content-type mime, optionally the charset $response->setContentType('application/pdf'); $response->setContentType('text/plain', 'UTF-8');
public setContentType ( string $contentType, string $charset = null ) : static
$contentType string
$charset string
Результат static

setCsvContent() публичный Метод

public setCsvContent ( array $rows, string $attachmentName, array | string $columns = null ) : static
$rows array
$attachmentName string
$columns array | string
Результат static

setEtag() публичный Метод

Set a custom ETag $response->setEtag(md5(time()));
public setEtag ( string $etag ) : static
$etag string
Результат static

setExpires() публичный Метод

Sets a Expires header to use HTTP cache $this->response->setExpires(new DateTime());
public setExpires ( integer $timestamp ) : static
$timestamp integer
Результат static

setFileToSend() публичный Метод

Sets an attached file to be sent at the end of the request
public setFileToSend ( string $file, string $attachmentName = null ) : static
$file string
$attachmentName string
Результат static

setHeader() публичный Метод

Overwrites a header in the response $response->setHeader("Content-Type", "text/plain");
public setHeader ( string $name, string $value ) : static
$name string
$value string
Результат static

setJsonContent() публичный Метод

Sets HTTP response body. The parameter is automatically converted to JSON $response->setJsonContent(array("status" => "OK")); $response->setJsonContent(array("status" => "OK"), JSON_NUMERIC_CHECK);
public setJsonContent ( array $content, integer $jsonOptions = null ) : static
$content array
$jsonOptions integer consisting on http://www.php.net/manual/en/json.constants.php
Результат static

setNotModified() публичный Метод

Sets a Not-Modified response
public setNotModified ( ) : static
Результат static

setRawHeader() публичный Метод

Send a raw header to the response $response->setRawHeader("HTTP/1.1 404 Not Found");
public setRawHeader ( string $header ) : static
$header string
Результат static

setStatusCode() публичный Метод

Sets the HTTP response code $response->setStatusCode(404, "Not Found");
public setStatusCode ( integer $code, string $message ) : static
$code integer
$message string
Результат static

Описание свойств

$_content защищенное свойство

protected string $_content
Результат string

$_file защищенное свойство

protected string $_file
Результат string

$_headers защищенное свойство

protected array $_headers
Результат array

$_sent защищенное свойство

protected bool $_sent
Результат boolean