PHP 클래스 Symfony\Component\HttpFoundation\Response

파일 보기 프로젝트 열기: symfony/symfony 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$headers ResponseHeaderBag
$statusTexts array The list of codes is complete according to the {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry} (last updated 2016-03-01). Unless otherwise noted, the status code is defined in RFC2616.

보호된 프로퍼티들

프로퍼티 타입 설명
$charset string
$content string
$statusCode integer
$statusText string
$version string

공개 메소드들

메소드 설명
__clone ( ) Clones the current Response instance.
__construct ( mixed $content = '', integer $status = 200, array $headers = [] ) Constructor.
__toString ( ) : string Returns the Response as an HTTP string.
closeOutputBuffers ( integer $targetLevel, boolean $flush ) Cleans or flushes output buffers up to target level.
create ( mixed $content = '', integer $status = 200, array $headers = [] ) : Response Factory method for chainability.
expire ( ) : Response Marks the response stale by setting the Age header to be equal to the maximum age of the response.
getAge ( ) : integer Returns the age of the response.
getCharset ( ) : string Retrieves the response charset.
getContent ( ) : string Gets the current response content.
getDate ( ) : DateTime Returns the Date header as a DateTime instance.
getEtag ( ) : string | null Returns the literal value of the ETag HTTP header.
getExpires ( ) : DateTime | null Returns the value of the Expires header as a DateTime instance.
getLastModified ( ) : DateTime | null Returns the Last-Modified HTTP header as a DateTime instance.
getMaxAge ( ) : integer | null Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.
getProtocolVersion ( ) : string Gets the HTTP protocol version.
getStatusCode ( ) : integer Retrieves the status code for the current web response.
getTtl ( ) : integer | null Returns the response's time-to-live in seconds.
getVary ( ) : array Returns an array of header names given in the Vary header.
hasVary ( ) : boolean Returns true if the response includes a Vary header.
isCacheable ( ) : boolean Returns true if the response is worth caching under any circumstance.
isClientError ( ) : boolean Is there a client error?
isEmpty ( ) : boolean Is the response empty?
isForbidden ( ) : boolean Is the response forbidden?
isFresh ( ) : boolean Returns true if the response is "fresh".
isInformational ( ) : boolean Is response informative?
isInvalid ( ) : boolean Is response invalid?
isNotFound ( ) : boolean Is the response a not found error?
isNotModified ( Request $request ) : boolean Determines if the Response validators (ETag, Last-Modified) match a conditional value specified in the Request.
isOk ( ) : boolean Is the response OK?
isRedirect ( string $location = null ) : boolean Is the response a redirect of some form?
isRedirection ( ) : boolean Is the response a redirect?
isServerError ( ) : boolean Was there a server side error?
isSuccessful ( ) : boolean Is response successful?
isValidateable ( ) : boolean Returns true if the response includes headers that can be used to validate the response with the origin server using a conditional GET request.
mustRevalidate ( ) : boolean Returns true if the response must be revalidated by caches.
prepare ( Request $request ) : Response Prepares the Response before it is sent to the client.
send ( ) : Response Sends HTTP headers and content.
sendContent ( ) : Response Sends content for the current web response.
sendHeaders ( ) : Response Sends HTTP headers.
setCache ( array $options ) : Response Sets the response's cache headers (validation and/or expiration).
setCharset ( string $charset ) : Response Sets the response charset.
setClientTtl ( integer $seconds ) : Response Sets the response's time-to-live for private/client caches.
setContent ( mixed $content ) : Response Sets the response content.
setDate ( DateTime $date ) : Response Sets the Date header.
setEtag ( string | null $etag = null, boolean $weak = false ) : Response Sets the ETag value.
setExpires ( DateTime $date = null ) : Response Sets the Expires HTTP header with a DateTime instance.
setLastModified ( DateTime $date = null ) : Response Sets the Last-Modified HTTP header with a DateTime instance.
setMaxAge ( integer $value ) : Response Sets the number of seconds after which the response should no longer be considered fresh.
setNotModified ( ) : Response Modifies the response so that it conforms to the rules defined for a 304 status code.
setPrivate ( ) : Response Marks the response as "private".
setProtocolVersion ( string $version ) : Response Sets the HTTP protocol version (1.0 or 1.1).
setPublic ( ) : Response Marks the response as "public".
setSharedMaxAge ( integer $value ) : Response Sets the number of seconds after which the response should no longer be considered fresh by shared caches.
setStatusCode ( integer $code, mixed $text = null ) : Response Sets the response status code.
setTtl ( integer $seconds ) : Response Sets the response's time-to-live for shared caches.
setVary ( string | array $headers, boolean $replace = true ) : Response Sets the Vary header.

보호된 메소드들

메소드 설명
ensureIEOverSSLCompatibility ( Request $request ) Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.

메소드 상세

__clone() 공개 메소드

Clones the current Response instance.
public __clone ( )

__construct() 공개 메소드

Constructor.
public __construct ( mixed $content = '', integer $status = 200, array $headers = [] )
$content mixed The response content, see setContent()
$status integer The response status code
$headers array An array of response headers

__toString() 공개 메소드

The string representation of the Response is the same as the one that will be sent to the client only if the prepare() method has been called before.
또한 보기: prepare()
public __toString ( ) : string
리턴 string The Response as an HTTP string

closeOutputBuffers() 공개 정적인 메소드

Resulting level can be greater than target level if a non-removable buffer has been encountered.
public static closeOutputBuffers ( integer $targetLevel, boolean $flush )
$targetLevel integer The target output buffering level
$flush boolean Whether to flush or clean the buffers

create() 공개 정적인 메소드

Example: return Response::create($body, 200) ->setSharedMaxAge(300);
public static create ( mixed $content = '', integer $status = 200, array $headers = [] ) : Response
$content mixed The response content, see setContent()
$status integer The response status code
$headers array An array of response headers
리턴 Response

ensureIEOverSSLCompatibility() 보호된 메소드

Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.
또한 보기: http://support.microsoft.com/kb/323308
protected ensureIEOverSSLCompatibility ( Request $request )
$request Request

expire() 공개 메소드

Marks the response stale by setting the Age header to be equal to the maximum age of the response.
public expire ( ) : Response
리턴 Response

getAge() 공개 메소드

Returns the age of the response.
public getAge ( ) : integer
리턴 integer The age of the response in seconds

getCharset() 공개 메소드

Retrieves the response charset.
public getCharset ( ) : string
리턴 string Character set

getContent() 공개 메소드

Gets the current response content.
public getContent ( ) : string
리턴 string Content

getDate() 공개 메소드

Returns the Date header as a DateTime instance.
public getDate ( ) : DateTime
리턴 DateTime A \DateTime instance

getEtag() 공개 메소드

Returns the literal value of the ETag HTTP header.
public getEtag ( ) : string | null
리턴 string | null The ETag HTTP header or null if it does not exist

getExpires() 공개 메소드

Returns the value of the Expires header as a DateTime instance.
public getExpires ( ) : DateTime | null
리턴 DateTime | null A DateTime instance or null if the header does not exist

getLastModified() 공개 메소드

Returns the Last-Modified HTTP header as a DateTime instance.
public getLastModified ( ) : DateTime | null
리턴 DateTime | null A DateTime instance or null if the header does not exist

getMaxAge() 공개 메소드

First, it checks for a s-maxage directive, then a max-age directive, and then it falls back on an expires header. It returns null when no maximum age can be established.
public getMaxAge ( ) : integer | null
리턴 integer | null Number of seconds

getProtocolVersion() 공개 메소드

Gets the HTTP protocol version.
public getProtocolVersion ( ) : string
리턴 string The HTTP protocol version

getStatusCode() 공개 메소드

Retrieves the status code for the current web response.
public getStatusCode ( ) : integer
리턴 integer Status code

getTtl() 공개 메소드

It returns null when no freshness information is present in the response. When the responses TTL is <= 0, the response may not be served from cache without first revalidating with the origin.
public getTtl ( ) : integer | null
리턴 integer | null The TTL in seconds

getVary() 공개 메소드

Returns an array of header names given in the Vary header.
public getVary ( ) : array
리턴 array An array of Vary names

hasVary() 공개 메소드

Returns true if the response includes a Vary header.
public hasVary ( ) : boolean
리턴 boolean true if the response includes a Vary header, false otherwise

isCacheable() 공개 메소드

Responses marked "private" with an explicit Cache-Control directive are considered uncacheable. Responses with neither a freshness lifetime (Expires, max-age) nor cache validator (Last-Modified, ETag) are considered uncacheable.
public isCacheable ( ) : boolean
리턴 boolean true if the response is worth caching, false otherwise

isClientError() 공개 메소드

Is there a client error?
public isClientError ( ) : boolean
리턴 boolean

isEmpty() 공개 메소드

Is the response empty?
public isEmpty ( ) : boolean
리턴 boolean

isForbidden() 공개 메소드

Is the response forbidden?
public isForbidden ( ) : boolean
리턴 boolean

isFresh() 공개 메소드

Fresh responses may be served from cache without any interaction with the origin. A response is considered fresh when it includes a Cache-Control/max-age indicator or Expires header and the calculated age is less than the freshness lifetime.
public isFresh ( ) : boolean
리턴 boolean true if the response is fresh, false otherwise

isInformational() 공개 메소드

Is response informative?
public isInformational ( ) : boolean
리턴 boolean

isInvalid() 공개 메소드

Is response invalid?
또한 보기: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
public isInvalid ( ) : boolean
리턴 boolean

isNotFound() 공개 메소드

Is the response a not found error?
public isNotFound ( ) : boolean
리턴 boolean

isNotModified() 공개 메소드

If the Response is not modified, it sets the status code to 304 and removes the actual content by calling the setNotModified() method.
public isNotModified ( Request $request ) : boolean
$request Request A Request instance
리턴 boolean true if the Response validators match the Request, false otherwise

isOk() 공개 메소드

Is the response OK?
public isOk ( ) : boolean
리턴 boolean

isRedirect() 공개 메소드

Is the response a redirect of some form?
public isRedirect ( string $location = null ) : boolean
$location string
리턴 boolean

isRedirection() 공개 메소드

Is the response a redirect?
public isRedirection ( ) : boolean
리턴 boolean

isServerError() 공개 메소드

Was there a server side error?
public isServerError ( ) : boolean
리턴 boolean

isSuccessful() 공개 메소드

Is response successful?
public isSuccessful ( ) : boolean
리턴 boolean

isValidateable() 공개 메소드

Returns true if the response includes headers that can be used to validate the response with the origin server using a conditional GET request.
public isValidateable ( ) : boolean
리턴 boolean true if the response is validateable, false otherwise

mustRevalidate() 공개 메소드

This method indicates that the response must not be served stale by a cache in any circumstance without first revalidating with the origin. When present, the TTL of the response should not be overridden to be greater than the value provided by the origin.
public mustRevalidate ( ) : boolean
리턴 boolean true if the response must be revalidated by a cache, false otherwise

prepare() 공개 메소드

This method tweaks the Response to ensure that it is compliant with RFC 2616. Most of the changes are based on the Request that is "associated" with this Response.
public prepare ( Request $request ) : Response
$request Request A Request instance
리턴 Response The current response

send() 공개 메소드

Sends HTTP headers and content.
public send ( ) : Response
리턴 Response

sendContent() 공개 메소드

Sends content for the current web response.
public sendContent ( ) : Response
리턴 Response

sendHeaders() 공개 메소드

Sends HTTP headers.
public sendHeaders ( ) : Response
리턴 Response

setCache() 공개 메소드

Available options are: etag, last_modified, max_age, s_maxage, private, and public.
public setCache ( array $options ) : Response
$options array An array of cache options
리턴 Response

setCharset() 공개 메소드

Sets the response charset.
public setCharset ( string $charset ) : Response
$charset string Character set
리턴 Response

setClientTtl() 공개 메소드

This method adjusts the Cache-Control/max-age directive.
public setClientTtl ( integer $seconds ) : Response
$seconds integer Number of seconds
리턴 Response

setContent() 공개 메소드

Valid types are strings, numbers, null, and objects that implement a __toString() method.
public setContent ( mixed $content ) : Response
$content mixed Content that can be cast to string
리턴 Response

setDate() 공개 메소드

Sets the Date header.
public setDate ( DateTime $date ) : Response
$date DateTime A \DateTime instance
리턴 Response

setEtag() 공개 메소드

Sets the ETag value.
public setEtag ( string | null $etag = null, boolean $weak = false ) : Response
$etag string | null The ETag unique identifier or null to remove the header
$weak boolean Whether you want a weak ETag or not
리턴 Response

setExpires() 공개 메소드

Passing null as value will remove the header.
public setExpires ( DateTime $date = null ) : Response
$date DateTime A \DateTime instance or null to remove the header
리턴 Response

setLastModified() 공개 메소드

Passing null as value will remove the header.
public setLastModified ( DateTime $date = null ) : Response
$date DateTime A \DateTime instance or null to remove the header
리턴 Response

setMaxAge() 공개 메소드

This methods sets the Cache-Control max-age directive.
public setMaxAge ( integer $value ) : Response
$value integer Number of seconds
리턴 Response

setNotModified() 공개 메소드

This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses.
또한 보기: http://tools.ietf.org/html/rfc2616#section-10.3.5
public setNotModified ( ) : Response
리턴 Response

setPrivate() 공개 메소드

It makes the response ineligible for serving other clients.
public setPrivate ( ) : Response
리턴 Response

setProtocolVersion() 공개 메소드

Sets the HTTP protocol version (1.0 or 1.1).
public setProtocolVersion ( string $version ) : Response
$version string The HTTP protocol version
리턴 Response

setPublic() 공개 메소드

It makes the response eligible for serving other clients.
public setPublic ( ) : Response
리턴 Response

setSharedMaxAge() 공개 메소드

This methods sets the Cache-Control s-maxage directive.
public setSharedMaxAge ( integer $value ) : Response
$value integer Number of seconds
리턴 Response

setStatusCode() 공개 메소드

Sets the response status code.
public setStatusCode ( integer $code, mixed $text = null ) : Response
$code integer HTTP status code
$text mixed HTTP status text If the status text is null it will be automatically populated for the known status codes and left empty otherwise.
리턴 Response

setTtl() 공개 메소드

This method adjusts the Cache-Control/s-maxage directive.
public setTtl ( integer $seconds ) : Response
$seconds integer Number of seconds
리턴 Response

setVary() 공개 메소드

Sets the Vary header.
public setVary ( string | array $headers, boolean $replace = true ) : Response
$headers string | array
$replace boolean Whether to replace the actual value or not (true by default)
리턴 Response

프로퍼티 상세

$charset 보호되어 있는 프로퍼티

protected string $charset
리턴 string

$content 보호되어 있는 프로퍼티

protected string $content
리턴 string

$headers 공개적으로 프로퍼티

public ResponseHeaderBag,Symfony\Component\HttpFoundation $headers
리턴 ResponseHeaderBag

$statusCode 보호되어 있는 프로퍼티

protected int $statusCode
리턴 integer

$statusText 보호되어 있는 프로퍼티

protected string $statusText
리턴 string

$statusTexts 공개적으로 정적으로 프로퍼티

The list of codes is complete according to the {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry} (last updated 2016-03-01). Unless otherwise noted, the status code is defined in RFC2616.
public static array $statusTexts
리턴 array

$version 보호되어 있는 프로퍼티

protected string $version
리턴 string