# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1349953493 -7200 # Node ID ba5afd9ff24ed22aeebf49ce7c0f4f763e6741b3 # Parent 0f1e08cdfff25f16db1b5a2de7ccd7c742896b99 Rename http-response-status-codes to StatusCodes diff -r 0f1e08cdfff2 -r ba5afd9ff24e StatusCodes.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/StatusCodes.inc Thu Oct 11 13:04:53 2012 +0200 @@ -0,0 +1,296 @@ +HTTP_CONTINUE + */ + const HTTP_CONTINUE = 100; + /** + * HTTP_SWITCHING_PROTOCOLS + */ + const HTTP_SWITCHING_PROTOCOLS = 101; + + // [Successful 2xx] + /** + * HTTP_OK + */ + const HTTP_OK = 200; + /** + * HTTP_CREATED + */ + const HTTP_CREATED = 201; + /** + * HTTP_ACCEPTED + */ + const HTTP_ACCEPTED = 202; + /** + * HTTP_ACCEPTED + */ + const HTTP_NONAUTHORITATIVE_INFORMATION = 203; + /** + * HTTP_NO_CONTENT + */ + const HTTP_NO_CONTENT = 204; + /** + * HTTP_RESET_CONTENT + */ + const HTTP_RESET_CONTENT = 205; + /** + * HTTP_PARTIAL_CONTENT + */ + const HTTP_PARTIAL_CONTENT = 206; + + // [Redirection 3xx] + /** + * HTTP_MULTIPLE_CHOICES + */ + const HTTP_MULTIPLE_CHOICES = 300; + /** + * HTTP_MOVED_PERMANENTLY + */ + const HTTP_MOVED_PERMANENTLY = 301; + /** + * HTTP_FOUND + */ + const HTTP_FOUND = 302; + /** + * HTTP_SEE_OTHER + */ + const HTTP_SEE_OTHER = 303; + /** + * HTTP_NOT_MODIFIED + */ + const HTTP_NOT_MODIFIED = 304; + /** + * HTTP_USE_PROXY + */ + const HTTP_USE_PROXY = 305; + /** + * HTTP_UNUSED + */ + const HTTP_UNUSED = 306; + /** + * HTTP_TEMPORARY_REDIRECT + */ + const HTTP_TEMPORARY_REDIRECT = 307; + + // [Client Error 4xx] + /** + * Defines the beginning of errorCodes + * @private + */ + const errorCodesBeginAt = 400; + /** + * HTTP_BAD_REQUEST + */ + const HTTP_BAD_REQUEST = 400; + /** + * HTTP_UNAUTHORIZED + */ + const HTTP_UNAUTHORIZED = 401; + /** + * HTTP_PAYMENT_REQUIRED + */ + const HTTP_PAYMENT_REQUIRED = 402; + /** + * HTTP_FORBIDDEN + */ + const HTTP_FORBIDDEN = 403; + /** + * HTTP_NOT_FOUND + */ + const HTTP_NOT_FOUND = 404; + /** + * HTTP_METHOD_NOT_ALLOWED + */ + const HTTP_METHOD_NOT_ALLOWED = 405; + /** + * HTTP_NOT_ACCEPTABLE + */ + const HTTP_NOT_ACCEPTABLE = 406; + /** + * HTTP_PROXY_AUTHENTICATION_REQUIRED + */ + const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; + /** + * HTTP_REQUEST_TIMEOUT + */ + const HTTP_REQUEST_TIMEOUT = 408; + /** + * HTTP_CONFLICT + */ + const HTTP_CONFLICT = 409; + /** + * HTTP_GONE + */ + const HTTP_GONE = 410; + /** + * HTTP_LENGTH_REQUIRED + */ + const HTTP_LENGTH_REQUIRED = 411; + /** + * HTTP_PRECONDITION_FAILED + */ + const HTTP_PRECONDITION_FAILED = 412; + /** + * HTTP_REQUEST_ENTITY_TOO_LARGE + */ + const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; + /** + * HTTP_REQUEST_URI_TOO_LONG + */ + const HTTP_REQUEST_URI_TOO_LONG = 414; + /** + * HTTP_UNSUPPORTED_MEDIA_TYPE + */ + const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; + /** + * HTTP_REQUESTED_RANGE_NOT_SATISFIABLE + */ + const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; + /** + * HTTP_EXPECTATION_FAILED + */ + const HTTP_EXPECTATION_FAILED = 417; + + // [Server Error 5xx] + /** + * HTTP_INTERNAL_SERVER_ERROR + */ + const HTTP_INTERNAL_SERVER_ERROR = 500; + /** + * HTTP_NOT_IMPLEMENTED + */ + const HTTP_NOT_IMPLEMENTED = 501; + /** + * HTTP_BAD_GATEWAY + */ + const HTTP_BAD_GATEWAY = 502; + /** + * HTTP_SERVICE_UNAVAILABLE + */ + const HTTP_SERVICE_UNAVAILABLE = 503; + /** + * HTTP_GATEWAY_TIMEOUT + */ + const HTTP_GATEWAY_TIMEOUT = 504; + /** + * HTTP_VERSION_NOT_SUPPORTED + */ + const HTTP_VERSION_NOT_SUPPORTED = 505; + + private static $messages = + array( + // [Informational 1xx] + 100=>'100 Continue', + 101=>'101 Switching Protocols', + + // [Successful 2xx] + 200=>'200 OK', + 201=>'201 Created', + 202=>'202 Accepted', + 203=>'203 Non-Authoritative Information', + 204=>'204 No Content', + 205=>'205 Reset Content', + 206=>'206 Partial Content', + + // [Redirection 3xx] + 300=>'300 Multiple Choices', + 301=>'301 Moved Permanently', + 302=>'302 Found', + 303=>'303 See Other', + 304=>'304 Not Modified', + 305=>'305 Use Proxy', + 306=>'306 (Unused)', + 307=>'307 Temporary Redirect', + + // [Client Error 4xx] + 400=>'400 Bad Request', + 401=>'401 Unauthorized', + 402=>'402 Payment Required', + 403=>'403 Forbidden', + 404=>'404 Not Found', + 405=>'405 Method Not Allowed', + 406=>'406 Not Acceptable', + 407=>'407 Proxy Authentication Required', + 408=>'408 Request Timeout', + 409=>'409 Conflict', + 410=>'410 Gone', + 411=>'411 Length Required', + 412=>'412 Precondition Failed', + 413=>'413 Request Entity Too Large', + 414=>'414 Request-URI Too Long', + 415=>'415 Unsupported Media Type', + 416=>'416 Requested Range Not Satisfiable', + 417=>'417 Expectation Failed', + + // [Server Error 5xx] + 500=>'500 Internal Server Error', + 501=>'501 Not Implemented', + 502=>'502 Bad Gateway', + 503=>'503 Service Unavailable', + 504=>'504 Gateway Timeout', + 505=>'505 HTTP Version Not Supported' + ); + + /** + * Get the header for the specified code. + * + * @param $code Http status code + * @return A textual representation of the header + */ + public static function httpHeaderFor($code) + { + return 'HTTP/1.1 ' . self::$messages[$code]; + } + + /** + * Get a canonical status message for the specified code + * + * @param $code Http status code + * @return Text for the specified code + */ + public static function getMessageForCode($code) + { + return self::$messages[$code]; + } + + /** + * Checks if the specified code is an error code. + * + * @param $code Http status code + * @return bool Answer + */ + public static function isError($code) + { + return is_numeric($code) && $code >= self::HTTP_BAD_REQUEST; + } + + /** + * Can the specified status code have a body? + * + * @param $code Http status code + * @return bool Answer + */ + public static function canHaveBody($code) + { + return + // True if not in 100s + ($code < self::HTTP_CONTINUE || $code >= self::HTTP_OK) + && // and not 204 NO CONTENT + $code != self::HTTP_NO_CONTENT + && // and not 304 NOT MODIFIED + $code != self::HTTP_NOT_MODIFIED; + } +} +?> \ No newline at end of file diff -r 0f1e08cdfff2 -r ba5afd9ff24e common-functions.inc --- a/common-functions.inc Thu Oct 11 01:07:17 2012 +0200 +++ b/common-functions.inc Thu Oct 11 13:04:53 2012 +0200 @@ -8,7 +8,7 @@ $baseDir = dirname(__FILE__); $cache = CacheTimeCheck::instance(__FILE__); -$cache->includeOnce('http-response-status-codes.inc', $baseDir); +$cache->includeOnce('StatusCodes.inc', $baseDir); function repMapString($map) { diff -r 0f1e08cdfff2 -r ba5afd9ff24e http-response-status-codes.inc --- a/http-response-status-codes.inc Thu Oct 11 01:07:17 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,296 +0,0 @@ -HTTP_CONTINUE - */ - const HTTP_CONTINUE = 100; - /** - * HTTP_SWITCHING_PROTOCOLS - */ - const HTTP_SWITCHING_PROTOCOLS = 101; - - // [Successful 2xx] - /** - * HTTP_OK - */ - const HTTP_OK = 200; - /** - * HTTP_CREATED - */ - const HTTP_CREATED = 201; - /** - * HTTP_ACCEPTED - */ - const HTTP_ACCEPTED = 202; - /** - * HTTP_ACCEPTED - */ - const HTTP_NONAUTHORITATIVE_INFORMATION = 203; - /** - * HTTP_NO_CONTENT - */ - const HTTP_NO_CONTENT = 204; - /** - * HTTP_RESET_CONTENT - */ - const HTTP_RESET_CONTENT = 205; - /** - * HTTP_PARTIAL_CONTENT - */ - const HTTP_PARTIAL_CONTENT = 206; - - // [Redirection 3xx] - /** - * HTTP_MULTIPLE_CHOICES - */ - const HTTP_MULTIPLE_CHOICES = 300; - /** - * HTTP_MOVED_PERMANENTLY - */ - const HTTP_MOVED_PERMANENTLY = 301; - /** - * HTTP_FOUND - */ - const HTTP_FOUND = 302; - /** - * HTTP_SEE_OTHER - */ - const HTTP_SEE_OTHER = 303; - /** - * HTTP_NOT_MODIFIED - */ - const HTTP_NOT_MODIFIED = 304; - /** - * HTTP_USE_PROXY - */ - const HTTP_USE_PROXY = 305; - /** - * HTTP_UNUSED - */ - const HTTP_UNUSED = 306; - /** - * HTTP_TEMPORARY_REDIRECT - */ - const HTTP_TEMPORARY_REDIRECT = 307; - - // [Client Error 4xx] - /** - * Defines the beginning of errorCodes - * @private - */ - const errorCodesBeginAt = 400; - /** - * HTTP_BAD_REQUEST - */ - const HTTP_BAD_REQUEST = 400; - /** - * HTTP_UNAUTHORIZED - */ - const HTTP_UNAUTHORIZED = 401; - /** - * HTTP_PAYMENT_REQUIRED - */ - const HTTP_PAYMENT_REQUIRED = 402; - /** - * HTTP_FORBIDDEN - */ - const HTTP_FORBIDDEN = 403; - /** - * HTTP_NOT_FOUND - */ - const HTTP_NOT_FOUND = 404; - /** - * HTTP_METHOD_NOT_ALLOWED - */ - const HTTP_METHOD_NOT_ALLOWED = 405; - /** - * HTTP_NOT_ACCEPTABLE - */ - const HTTP_NOT_ACCEPTABLE = 406; - /** - * HTTP_PROXY_AUTHENTICATION_REQUIRED - */ - const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; - /** - * HTTP_REQUEST_TIMEOUT - */ - const HTTP_REQUEST_TIMEOUT = 408; - /** - * HTTP_CONFLICT - */ - const HTTP_CONFLICT = 409; - /** - * HTTP_GONE - */ - const HTTP_GONE = 410; - /** - * HTTP_LENGTH_REQUIRED - */ - const HTTP_LENGTH_REQUIRED = 411; - /** - * HTTP_PRECONDITION_FAILED - */ - const HTTP_PRECONDITION_FAILED = 412; - /** - * HTTP_REQUEST_ENTITY_TOO_LARGE - */ - const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; - /** - * HTTP_REQUEST_URI_TOO_LONG - */ - const HTTP_REQUEST_URI_TOO_LONG = 414; - /** - * HTTP_UNSUPPORTED_MEDIA_TYPE - */ - const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; - /** - * HTTP_REQUESTED_RANGE_NOT_SATISFIABLE - */ - const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; - /** - * HTTP_EXPECTATION_FAILED - */ - const HTTP_EXPECTATION_FAILED = 417; - - // [Server Error 5xx] - /** - * HTTP_INTERNAL_SERVER_ERROR - */ - const HTTP_INTERNAL_SERVER_ERROR = 500; - /** - * HTTP_NOT_IMPLEMENTED - */ - const HTTP_NOT_IMPLEMENTED = 501; - /** - * HTTP_BAD_GATEWAY - */ - const HTTP_BAD_GATEWAY = 502; - /** - * HTTP_SERVICE_UNAVAILABLE - */ - const HTTP_SERVICE_UNAVAILABLE = 503; - /** - * HTTP_GATEWAY_TIMEOUT - */ - const HTTP_GATEWAY_TIMEOUT = 504; - /** - * HTTP_VERSION_NOT_SUPPORTED - */ - const HTTP_VERSION_NOT_SUPPORTED = 505; - - private static $messages = - array( - // [Informational 1xx] - 100=>'100 Continue', - 101=>'101 Switching Protocols', - - // [Successful 2xx] - 200=>'200 OK', - 201=>'201 Created', - 202=>'202 Accepted', - 203=>'203 Non-Authoritative Information', - 204=>'204 No Content', - 205=>'205 Reset Content', - 206=>'206 Partial Content', - - // [Redirection 3xx] - 300=>'300 Multiple Choices', - 301=>'301 Moved Permanently', - 302=>'302 Found', - 303=>'303 See Other', - 304=>'304 Not Modified', - 305=>'305 Use Proxy', - 306=>'306 (Unused)', - 307=>'307 Temporary Redirect', - - // [Client Error 4xx] - 400=>'400 Bad Request', - 401=>'401 Unauthorized', - 402=>'402 Payment Required', - 403=>'403 Forbidden', - 404=>'404 Not Found', - 405=>'405 Method Not Allowed', - 406=>'406 Not Acceptable', - 407=>'407 Proxy Authentication Required', - 408=>'408 Request Timeout', - 409=>'409 Conflict', - 410=>'410 Gone', - 411=>'411 Length Required', - 412=>'412 Precondition Failed', - 413=>'413 Request Entity Too Large', - 414=>'414 Request-URI Too Long', - 415=>'415 Unsupported Media Type', - 416=>'416 Requested Range Not Satisfiable', - 417=>'417 Expectation Failed', - - // [Server Error 5xx] - 500=>'500 Internal Server Error', - 501=>'501 Not Implemented', - 502=>'502 Bad Gateway', - 503=>'503 Service Unavailable', - 504=>'504 Gateway Timeout', - 505=>'505 HTTP Version Not Supported' - ); - - /** - * Get the header for the specified code. - * - * @param $code Http status code - * @return A textual representation of the header - */ - public static function httpHeaderFor($code) - { - return 'HTTP/1.1 ' . self::$messages[$code]; - } - - /** - * Get a canonical status message for the specified code - * - * @param $code Http status code - * @return Text for the specified code - */ - public static function getMessageForCode($code) - { - return self::$messages[$code]; - } - - /** - * Checks if the specified code is an error code. - * - * @param $code Http status code - * @return bool Answer - */ - public static function isError($code) - { - return is_numeric($code) && $code >= self::HTTP_BAD_REQUEST; - } - - /** - * Can the specified status code have a body? - * - * @param $code Http status code - * @return bool Answer - */ - public static function canHaveBody($code) - { - return - // True if not in 100s - ($code < self::HTTP_CONTINUE || $code >= self::HTTP_OK) - && // and not 204 NO CONTENT - $code != self::HTTP_NO_CONTENT - && // and not 304 NOT MODIFIED - $code != self::HTTP_NOT_MODIFIED; - } -} -?> \ No newline at end of file