PHP Class Neos\Flow\Http\Response

Inheritance: extends AbstractMessage, implements Neos\Flow\Mvc\ResponseInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$now DateTime The current point in time, used for comparisons
$parentResponse Response
$statusCode integer The HTTP status code
$statusMessage string The HTTP status message

Méthodes publiques

Méthode Description
__construct ( Response $parentResponse = null ) Construct this Response
__toString ( ) : string Cast the response to a string: return the content part of this response
appendContent ( string $content ) : Response Appends content to the already existing content.
createFromRaw ( string $rawResponse, Response $parentResponse = null ) : Response Creates a response from the given raw, that is plain text, HTTP response.
getAge ( ) : integer Returns the age of this responds in seconds.
getContent ( ) : string Returns the response content without sending it.
getDate ( ) : DateTime Returns the date from the Date header.
getExpires ( ) : DateTime Returns the date from the Expires header or NULL if no such header is present.
getLastModified ( ) : DateTime Returns the date from the Last-Modified header or NULL if no such header is present.
getMaximumAge ( ) : integer Returns the maximum age in seconds before this response becomes stale.
getParentResponse ( ) : Response Return the parent response or NULL if none exists.
getSharedMaximumAge ( ) : integer Returns the maximum age in seconds before this response becomes stale in shared caches, such as proxies.
getStartLine ( ) : string Returns the first line of this Response Message, which is the Status-Line in this case
getStatus ( ) : string Returns status code and status message.
getStatusCode ( ) : integer Returns the status code.
getStatusLine ( ) : string Return the Status-Line of this Response Message, consisting of the version, the status code and the reason phrase Would be, for example, "HTTP/1.1 200 OK" or "HTTP/1.1 400 Bad Request"
getStatusMessageByCode ( integer $statusCode ) : string Returns the human-readable message for the given status code.
makeStandardsCompliant ( Request $request ) : void Analyzes this response, considering the given request and makes additions or removes certain headers in order to make the response compliant to RFC 2616 and related standards.
renderHeaders ( ) : array Renders the HTTP headers - including the status header - of this response
send ( ) : void Renders and sends the whole web response
sendHeaders ( ) : void Sends the HTTP headers.
setDate ( string | DateTime $date ) : Response Sets the Date header.
setExpires ( string | DateTime $date ) : Response Sets the Expires header.
setHeaders ( Headers $headers ) : void Replaces all possibly existing HTTP headers with the ones specified
setLastModified ( string | DateTime $date ) : Response Sets the Last-Modified header.
setMaximumAge ( integer $age ) : Response Sets the maximum age in seconds before this response becomes stale.
setNow ( DateTime $now ) : void Sets the current point in time.
setPrivate ( ) : Response Sets the respective directive in the Cache-Control header.
setPublic ( ) : Response Sets the respective directive in the Cache-Control header.
setSharedMaximumAge ( integer $maximumAge ) : Response Sets the maximum age in seconds before this response becomes stale in shared caches, such as proxies.
setStatus ( integer $code, string $message = null ) : Response Sets the HTTP status code and (optionally) a customized message.

Method Details

__construct() public méthode

Construct this Response
public __construct ( Response $parentResponse = null )
$parentResponse Response

__toString() public méthode

Cast the response to a string: return the content part of this response
public __toString ( ) : string
Résultat string The same as getContent(), an empty string if getContent() returns a value which can't be cast into a string

appendContent() public méthode

Appends content to the already existing content.
public appendContent ( string $content ) : Response
$content string More response content
Résultat Response This response, for method chaining

createFromRaw() public static méthode

Creates a response from the given raw, that is plain text, HTTP response.
public static createFromRaw ( string $rawResponse, Response $parentResponse = null ) : Response
$rawResponse string
$parentResponse Response Parent response, if called recursively
Résultat Response

getAge() public méthode

The age is determined either by an explicitly set Age header or by the difference between Date and "now". Note that, according to RFC 2616 / 13.2.3, the presence of an Age header implies that the response is not first-hand. You should therefore only explicitly set an Age header if this is the case.
public getAge ( ) : integer
Résultat integer The age in seconds

getContent() public méthode

Returns the response content without sending it.
public getContent ( ) : string
Résultat string The response content

getDate() public méthode

The returned date is configured to be in the GMT timezone.
public getDate ( ) : DateTime
Résultat DateTime The date of this response

getExpires() public méthode

The returned date is configured to be in the GMT timezone.
public getExpires ( ) : DateTime
Résultat DateTime The expiration date or NULL

getLastModified() public méthode

The returned date is configured to be in the GMT timezone.
public getLastModified ( ) : DateTime
Résultat DateTime The last modification date or NULL

getMaximumAge() public méthode

This method returns the value from the "max-age" directive in the Cache-Control header.
public getMaximumAge ( ) : integer
Résultat integer The maximum age in seconds, or NULL if none has been defined

getParentResponse() public méthode

Return the parent response or NULL if none exists.
public getParentResponse ( ) : Response
Résultat Response the parent response, or NULL if none

getSharedMaximumAge() public méthode

This method returns the value from the "s-maxage" directive in the Cache-Control header.
public getSharedMaximumAge ( ) : integer
Résultat integer The maximum age in seconds, or NULL if none has been defined

getStartLine() public méthode

Returns the first line of this Response Message, which is the Status-Line in this case
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html chapter 4.1 "Message Types"
public getStartLine ( ) : string
Résultat string The Status-Line of this Response

getStatus() public méthode

Returns status code and status message.
public getStatus ( ) : string
Résultat string The status code and status message, eg. "404 Not Found"

getStatusCode() public méthode

Returns the status code.
public getStatusCode ( ) : integer
Résultat integer The status code, eg. 404

getStatusLine() public méthode

Return the Status-Line of this Response Message, consisting of the version, the status code and the reason phrase Would be, for example, "HTTP/1.1 200 OK" or "HTTP/1.1 400 Bad Request"
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
public getStatusLine ( ) : string
Résultat string

getStatusMessageByCode() public static méthode

Returns the human-readable message for the given status code.
public static getStatusMessageByCode ( integer $statusCode ) : string
$statusCode integer
Résultat string

makeStandardsCompliant() public méthode

It is recommended to call this method before the response is sent and Flow does so by default in its built-in HTTP request handler.
public makeStandardsCompliant ( Request $request ) : void
$request Request The corresponding request
Résultat void

renderHeaders() public méthode

Renders the HTTP headers - including the status header - of this response
public renderHeaders ( ) : array
Résultat array The HTTP headers

send() public méthode

Renders and sends the whole web response
public send ( ) : void
Résultat void

sendHeaders() public méthode

If headers have been sent previously, this method fails silently.
public sendHeaders ( ) : void
Résultat void

setDate() public méthode

The given date must either be an RFC2822 parseable date string or a DateTime object. The timezone will be converted to GMT internally, but the point in time remains the same.
public setDate ( string | DateTime $date ) : Response
$date string | DateTime
Résultat Response This response, for method chaining

setExpires() public méthode

The given date must either be an RFC2822 parseable date string or a DateTime object. The timezone will be converted to GMT internally, but the point in time remains the same. In order to signal that the response has already expired, the date should be set to the same date as the Date header (that is, $now). To communicate an infinite expiration time, the date should be set to one year in the future. Expiration times should not be more than one year in the future, according to RFC 2616 / 14.21
public setExpires ( string | DateTime $date ) : Response
$date string | DateTime
Résultat Response This response, for method chaining

setHeaders() public méthode

Replaces all possibly existing HTTP headers with the ones specified
public setHeaders ( Headers $headers ) : void
$headers Headers
Résultat void

setLastModified() public méthode

The given date must either be an RFC2822 parseable date string or a DateTime object. The timezone will be converted to GMT internally, but the point in time remains the same.
public setLastModified ( string | DateTime $date ) : Response
$date string | DateTime
Résultat Response This response, for method chaining

setMaximumAge() public méthode

This method sets the "max-age" directive in the Cache-Control header.
public setMaximumAge ( integer $age ) : Response
$age integer The maximum age in seconds
Résultat Response This response, for method chaining

setNow() public méthode

This date / time is used internally for comparisons in order to determine the freshness of this response. By default this DateTime object is set automatically through dependency injection, configured in the Objects.yaml of the Flow package. Unless you are mocking the current time in a test, there is probably no need to use this function. Also note that this method must be called before any of the Response methods are used and it must not be called a second time.
public setNow ( DateTime $now ) : void
$now DateTime The current point in time
Résultat void

setPrivate() public méthode

A response flagged as "private" tells that it is intended for a specific user and must not be cached by a shared cache.
public setPrivate ( ) : Response
Résultat Response This response, for method chaining

setPublic() public méthode

A response flagged as "public" may be cached by any cache, even if it normally wouldn't be cacheable in a shared cache.
public setPublic ( ) : Response
Résultat Response This response, for method chaining

setSharedMaximumAge() public méthode

This method sets the "s-maxage" directive in the Cache-Control header.
public setSharedMaximumAge ( integer $maximumAge ) : Response
$maximumAge integer The maximum age in seconds
Résultat Response This response, for method chaining

setStatus() public méthode

Sets the HTTP status code and (optionally) a customized message.
public setStatus ( integer $code, string $message = null ) : Response
$code integer The status code
$message string If specified, this message is sent instead of the standard message
Résultat Response This response, for method chaining

Property Details

$now protected_oe property

The current point in time, used for comparisons
protected DateTime $now
Résultat DateTime

$parentResponse protected_oe property

protected Response,Neos\Flow\Http $parentResponse
Résultat Response

$statusCode protected_oe property

The HTTP status code
protected int $statusCode
Résultat integer

$statusMessage protected_oe property

The HTTP status message
protected string $statusMessage
Résultat string