Exceptions.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. return '';
  15. }
  16. /**
  17. * List of common Http code
  18. */
  19. static public function getCodes(){
  20. return array(
  21. 200 => 'OK',
  22. 201 => 'Created',
  23. 202 => 'Accepted',
  24. 300 => 'Multiple Choices',
  25. 301 => 'Moved Permanently',
  26. 302 => 'Moved Temporarily',
  27. 307 => 'Temporary Redirect',
  28. 310 => 'Too many Redirects',
  29. 400 => 'Bad Request',
  30. 401 => 'Unauthorized',
  31. 402 => 'Payment Required',
  32. 403 => 'Forbidden',
  33. 404 => 'Not Found',
  34. 405 => 'Method Not',
  35. 406 => 'Not Acceptable',
  36. 407 => 'Proxy Authentication Required',
  37. 408 => 'Request Time-out',
  38. 409 => 'Conflict',
  39. 410 => 'Gone',
  40. 411 => 'Length Required',
  41. 412 => 'Precondition Failed',
  42. 413 => 'Request Entity Too Large',
  43. 414 => 'Request-URI Too Long',
  44. 415 => 'Unsupported Media Type',
  45. 416 => 'Requested range unsatisfiable',
  46. 417 => 'Expectation failed',
  47. 500 => 'Internal Server Error',
  48. 501 => 'Not Implemented',
  49. 502 => 'Bad Gateway',
  50. 503 => 'Service Unavailable',
  51. 504 => 'Gateway Time-out',
  52. 508 => 'Loop detected',
  53. );
  54. }
  55. }