PHP 클래스 ManaPHP\Http\Response

상속: extends ManaPHP\Component, implements ManaPHP\Http\ResponseInterface
파일 보기 프로젝트 열기: manaphp/manaphp

보호된 프로퍼티들

프로퍼티 타입 설명
$_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