============== HTTP Responses ============== The [`Solar_Http_Response`](/class/Solar_Http_Response) represents an HTTP response, either one from an HTTP request, or one you are building to send to a client. When you use Solar_Http_Request to fetch a response, you can explore the response by getting the response code, response text, HTTP version, headers, cookies, and content -- all pretty standard stuff. You can also build a new `Solar_Http_Response` on your own and send that from your application. This has the benefit of giving you relatively good control over headers, response codes, etc., so that you can pass the values around to different parts of your application before sending the final response. (It also sanitizes header values automatically, which can be a nice addition for secure coding practices.) {{code: php $response = Solar::factory('Solar_Http_Response'); $response->setResponseCode('200') // auto-sets response text to "Ok" ->setHeader('X-Example', 'Custom header value') ->setCookie('foo', 'bar') // sets "Cookie: foo=bar" header ->setContent('

Hello world!

'); // sends sanitized headers and prints the content $response->display(); }} [`Solar_Controller_Page`](/class/Solar_Controller_Page), for example, builds up a [[Solar_Controller_Page::$_response | $_response]] object internally, which it then [[Solar_Controller_Page::fetch() | returns for display]] by the calling code (generally the front controller and/or bootstrap script). Here's another example, where we send a custom 5xx response code with a special response message: {{code: php $response = Solar::factory('Solar_Http_Response'); $response->setResponseCode('599') ->setResponseText('Custom server error message') ->setContent('Sorry, something went wrong.'); $response->display(); }}