PHP Класс Symfony\Component\HttpFoundation\Response

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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.

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

Свойство Тип Описание
$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