Version: current

# Class SS_HTTPResponse

Represents a response returned by a controller.

### Direct known subclasses

`RestfulService_Response`

Package: sapphire\control
Located at sapphire/core/control/HTTPResponse.php

## Methods summary

`public` | # `__construct( mixed $body = null, mixed $statusCode = null, mixed $statusDescription = null )` Create a new HTTP response Create a new HTTP response #### Parameters $body $body The body of the response $statusCode $statusCode The numeric status code - 200, 404, etc $statusDescription $statusDescription The text to be given alongside the status code. This can be accessed by javascript
`public` | # `setStatusCode( mixed $code, mixed $description = null )`
`public` | # `getStatusCode( )`
`public string` | # `getStatusDescription( )` #### Returns `string` Description for a HTTP status code
`public` | # `isError( )` Returns true if this HTTP response is in error Returns true if this HTTP response is in error
`public` | # `setBody( mixed $body )`
`public` | # `getBody( )`
`public` | # `addHeader( string $header, string $value )` Add a HTTP header to the response, replacing any header of the same name. Add a HTTP header to the response, replacing any header of the same name. #### Parameters $header string $header Example: "Content-Type" $value string $value Example: "text/xml"
`public` | # `getHeader( string $header )` Return the HTTP header of the given name. Return the HTTP header of the given name. #### Parameters $header string $header #### Returns string
`public array` | # `getHeaders( )` #### Returns `array` array
`public` | # `removeHeader( unknown_type $header )` Remove an existing HTTP header by its name, e.g. "Content-Type". Remove an existing HTTP header by its name, e.g. "Content-Type". #### Parameters $header unknown_type $header
`public` | # `redirect( mixed $dest, mixed $code = 302 )`
`public` | # `output( )` Send this HTTPReponse to the browser Send this HTTPReponse to the browser
`public` | # `isFinished( )` Returns true if this response is "finished", that is, no more script execution should be done. Specifically, returns true if a redirect has already been requested Returns true if this response is "finished", that is, no more script execution should be done. Specifically, returns true if a redirect has already been requested
`public` | # `getLinks( )` #### Deprecated 2.4 Use `HTTP::getLinksIn()` on DOMDocument.

### Magic methods summary

## Properties summary

`protected static array` | $status_codes | #
`protected static array` | $redirect_codes | #
`protected integer` | $statusCode | #
`protected string` | $statusDescription | #
`protected array` | $headers | # HTTP Headers like "Content-Type: text/xml" HTTP Headers like "Content-Type: text/xml" #### See http://en.wikipedia.org/wiki/List_of_HTTP_headers
`protected string` | $body | #

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -