Exceptions.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. class HttpException extends \Exception{}
  3. /**
  4. * Not real http implementation but only utils stuff
  5. */
  6. class Http{
  7. /**
  8. * Return message corresponding to Http code
  9. */
  10. static public function getMessageForCode($code){
  11. $codes = self::getCodes();
  12. if( isset($codes[$code]) ){
  13. return $codes[$code];
  14. }
  15. return '';
  16. }
  17. /**
  18. * List of common Http code
  19. */
  20. static public function getCodes(){
  21. return array(
  22. 200 => 'OK',
  23. 201 => 'Created',
  24. 202 => 'Accepted',
  25. 300 => 'Multiple Choices',
  26. 301 => 'Moved Permanently',
  27. 302 => 'Moved Temporarily',
  28. 307 => 'Temporary Redirect',
  29. 310 => 'Too many Redirects',
  30. 400 => 'Bad Request',
  31. 401 => 'Unauthorized',
  32. 402 => 'Payment Required',
  33. 403 => 'Forbidden',
  34. 404 => 'Not Found',
  35. 405 => 'Method Not',
  36. 406 => 'Not Acceptable',
  37. 407 => 'Proxy Authentication Required',
  38. 408 => 'Request Time-out',
  39. 409 => 'Conflict',
  40. 410 => 'Gone',
  41. 411 => 'Length Required',
  42. 412 => 'Precondition Failed',
  43. 413 => 'Request Entity Too Large',
  44. 414 => 'Request-URI Too Long',
  45. 415 => 'Unsupported Media Type',
  46. 416 => 'Requested range unsatisfiable',
  47. 417 => 'Expectation failed',
  48. 500 => 'Internal Server Error',
  49. 501 => 'Not Implemented',
  50. 502 => 'Bad Gateway',
  51. 503 => 'Service Unavailable',
  52. 504 => 'Gateway Time-out',
  53. 508 => 'Loop detected',
  54. );
  55. }
  56. }