'Continue', self::STATUS_101 => 'Switching Protocols', self::STATUS_200 => 'OK', self::STATUS_201 => 'Created', self::STATUS_202 => 'Accepted', self::STATUS_203 => 'Non-Authoritative Information', self::STATUS_204 => 'No Content', self::STATUS_205 => 'Reset Content', self::STATUS_206 => 'Partial Content', self::STATUS_207 => 'Multi-Status', self::STATUS_300 => 'Multiple Choices', self::STATUS_301 => 'Moved Permanently', self::STATUS_302 => 'Moved Temporarily', self::STATUS_303 => 'See Other', self::STATUS_304 => 'Not Modified', self::STATUS_305 => 'Use Proxy', self::STATUS_400 => 'Bad Request', self::STATUS_401 => 'Unauthorized', self::STATUS_402 => 'Payment Required', self::STATUS_403 => 'Forbidden', self::STATUS_404 => 'Not Found', self::STATUS_405 => 'Method Not Allowed', self::STATUS_406 => 'Not Acceptable', self::STATUS_407 => 'Proxy Authentication Required', self::STATUS_408 => 'Request Time-out', self::STATUS_409 => 'Conflict', self::STATUS_410 => 'Gone', self::STATUS_411 => 'Length Required', self::STATUS_412 => 'Precondition Failed', self::STATUS_413 => 'Request Entity Too Large', self::STATUS_414 => 'Request-URI Too Large', self::STATUS_415 => 'Unsupported Media Type', self::STATUS_423 => 'Locked', self::STATUS_424 => 'Failed Dependency', self::STATUS_500 => 'Internal Server Error', self::STATUS_501 => 'Not Implemented', self::STATUS_502 => 'Bad Gateway', self::STATUS_503 => 'Service Unavailable', self::STATUS_504 => 'Gateway Time-out', self::STATUS_505 => 'HTTP Version not supported', self::STATUS_507 => 'Insufficient Storage', ); /** * Container to hold the properties * * @var array(string=>mixed) */ protected $properties = array( 'responseDescription' => null, ); /** * Container for header information. * * @var array(string=>mixed) */ protected $headers = array(); /** * Construct error response from status. * * @param int $status * @return void */ public function __construct( $status = self::STATUS_200 ) { $this->status = $status; } /** * Validates the headers set in this request. * This method is called by ezcWebdavServer after the response object has * been created by an ezcWebdavBackend. It must validate all headers * specific for this request for existance of required headers and validity * of all headers used by the specific request implementation. The call of * the parent method is *mandatory* to have common WebDAV and HTTP headers * validated, too! * * @return void * * @throws ezcWebdavMissingHeaderException * if a required header is missing. * @throws ezcWebdavInvalidHeaderException * if a header is present, but its content does not validate. */ public function validateHeaders() { // set in ezcWebdavTransport::handleResponse() if ( !isset( $this->headers['Server'] ) ) { throw new ezcWebdavMissingHeaderException( 'Server' ); } // @TODO: Do we need more standard HTTP headers here? } /** * Sets a header to a specified value. * Sets the value for $header to $headerValue. All processable headers will * be validated centrally in {@link validateHeaders()}. * * For validation of header content, the method {@link validateHeaders()} * can be overwritten. * * @param string $headerName * @param mixed $headerValue * @return void */ public final function setHeader( $headerName, $headerValue ) { $this->headers[$headerName] = $headerValue; } /** * Returns the contents of a specific header. * Returns the content of the header identified with $headerName with the * given name and null if no content for the header is available. * * @param string $headerName * @return mixed */ public final function getHeader( $headerName ) { return isset( $this->headers[$headerName] ) ? $this->headers[$headerName] : null; } /** * Returns all headers. * * @return array(string=>string) */ public final function getHeaders() { return $this->headers; } /** * Sets a property. * This method is called when an property is to be set. * * @param string $propertyName The name of the property to set. * @param mixed $propertyValue The property value. * @ignore * * @throws ezcBasePropertyNotFoundException * if the given property does not exist. * @throws ezcBaseValueException * if the value to be assigned to a property is invalid. * @throws ezcBasePropertyPermissionException * if the property to be set is a read-only property. */ public function __set( $propertyName, $propertyValue ) { switch ( $propertyName ) { case 'status': if ( !isset( self::$errorNames[$propertyValue] ) ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'HTTP error code' ); } $this->properties[$propertyName] = $propertyValue; break; case 'responseDescription': if ( !is_string( $propertyValue ) ) { throw new ezcBaseValueException( $propertyName, $propertyValue, 'string' ); } $this->properties[$propertyName] = $propertyValue; break; default: throw new ezcBasePropertyNotFoundException( $propertyName ); } } /** * Property get access. * Simply returns a given property. * * @throws ezcBasePropertyNotFoundException * If a the value for the property propertys is not an instance of * @param string $propertyName The name of the property to get. * @return mixed The property value. * * @ignore * * @throws ezcBasePropertyNotFoundException * if the given property does not exist. * @throws ezcBasePropertyPermissionException * if the property to be set is a write-only property. */ public function __get( $propertyName ) { if ( $this->__isset( $propertyName ) === true ) { return $this->properties[$propertyName]; } throw new ezcBasePropertyNotFoundException( $propertyName ); } /** * Returns if a property exists. * Returns true if the property exists in the {@link $properties} array * (even if it is null) and false otherwise. * * @param string $propertyName Option name to check for. * @return void * @ignore */ public function __isset( $propertyName ) { return array_key_exists( $propertyName, $this->properties ); } /** * Return valid HTTP response string from error code. * * @return string */ public function __toString() { return 'HTTP/1.1 ' . $this->status . ' ' . self::$errorNames[$this->status]; } } ?>