Source for file HttpResponse.php
Documentation is available at HttpResponse.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @package RequestResponse
* @copyright Copyright (c) 2007 Sven Strittmatter
require_once dirname(__FILE__ ). "/../Response.php";
* @see GenerallHttpHeaders
require_once dirname(__FILE__ ). "/GenerallHttpHeaders.php";
* Enter description here...
* @todo complete description
* @package RequestResponse
* @copyright Copyright (c) 2007 Sven Strittmatter
* @author "Sven Strittmatter" <ausserirdisch@sven-space.de>
* @link http://www.sven-space.de/code/php/MVClasses
class HttpResponse implements Response, GenerallHttpHeaders {
const HTTP_STATUS_100 = "100 Continue";
const HTTP_STATUS_101 = "101 Switching Protocols";
const HTTP_STATUS_102 = "102 Processing";
// Succesfull operations:
const HTTP_STATUS_200 = "200 OK";
const HTTP_STATUS_201 = "201 Created";
const HTTP_STATUS_202 = "202 Accepted";
const HTTP_STATUS_203 = "203 Non-Authoritative Information";
const HTTP_STATUS_204 = "204 No Content";
const HTTP_STATUS_205 = "205 Reset Content";
const HTTP_STATUS_206 = "206 Partial Content";
const HTTP_STATUS_207 = "207 Multi-Status";
const HTTP_STATUS_300 = "300 Multiple Choice";
const HTTP_STATUS_301 = "301 Moved Permanently";
const HTTP_STATUS_302 = "302 Found";
const HTTP_STATUS_303 = "303 See Other";
const HTTP_STATUS_304 = "304 Not Modified";
const HTTP_STATUS_305 = "305 Use Proxy";
const HTTP_STATUS_307 = "307 Temporary Redirect";
const HTTP_STATUS_400 = "400 Bad Request";
const HTTP_STATUS_401 = "401 Unauthorized";
const HTTP_STATUS_402 = "402 Payment Required";
const HTTP_STATUS_403 = "403 Forbidden";
const HTTP_STATUS_404 = "404 Not Found";
const HTTP_STATUS_405 = "405 Method Not Allowed";
const HTTP_STATUS_406 = "406 Not Acceptable";
const HTTP_STATUS_407 = "407 Proxy Authentication Required";
const HTTP_STATUS_408 = "408 Request Time-out";
const HTTP_STATUS_409 = "409 Conflict";
const HTTP_STATUS_410 = "410 Gone";
const HTTP_STATUS_411 = "411 Length Required";
const HTTP_STATUS_412 = "412 Precondition Failed";
const HTTP_STATUS_413 = "413 Request Entity Too Large";
const HTTP_STATUS_414 = "414 Request-URI Too Long";
const HTTP_STATUS_415 = "415 Unsupported Media Type";
const HTTP_STATUS_416 = "416 Requested range not satisfiable";
const HTTP_STATUS_417 = "417 Expectation Failed";
const HTTP_STATUS_422 = "422 Unprocessable Entity";
const HTTP_STATUS_423 = "423 Locked";
const HTTP_STATUS_424 = "424 Failed Dependency";
const HTTP_STATUS_500 = "500 Internal Server Error";
const HTTP_STATUS_501 = "501 Not Implemented";
const HTTP_STATUS_502 = "502 Bad Gateway";
const HTTP_STATUS_503 = "503 Service Unavailable";
const HTTP_STATUS_504 = "504 Gateway Time-out";
const HTTP_STATUS_505 = "505 HTTP Version not supported";
const HTTP_STATUS_507 = "507 Insufficient Storage";
const HTTP_STATUS_509 = "509 Bandwidth Limit Exceeded";
// konstanten fuer headers (http://www.bolege.de/http-header/#art2)
const HTTP_HEADER_AGE = "Age";
const HTTP_HEADER_ETAG = "ETag";
const HTTP_HEADER_LOCATION = "Location";
const HTTP_HEADER_PROXY_AUTHENITACION = "Proxy-Authenticate";
const HTTP_HEADER_SET_COOKIE = "Set-cookie";
const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
const HTTP_HEADER_SERVER = "Server";
const HTTP_HEADER_RETRY_AFTER = "Retry-after";
$this->_status = self::HTTP_STATUS_200;
$this->_headers = array();
$this->_status = $status;
$this->_headers[$name] = $value;
public function write($data) {
public function flush() {
header("HTTP/1.1 {$this->_status}");
foreach ($this->_headers as $name => $value) {
header("{ $name}: { $value}");
$this->_headers = array();
public function getBody() {
public function setBody($body) {
|