StatusCodeInterface.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace Fig\Http\Message;
  3. /**
  4. * Defines constants for common HTTP status code.
  5. *
  6. * @see https://tools.ietf.org/html/rfc2295#section-8.1
  7. * @see https://tools.ietf.org/html/rfc2324#section-2.3
  8. * @see https://tools.ietf.org/html/rfc2518#section-9.7
  9. * @see https://tools.ietf.org/html/rfc2774#section-7
  10. * @see https://tools.ietf.org/html/rfc3229#section-10.4
  11. * @see https://tools.ietf.org/html/rfc4918#section-11
  12. * @see https://tools.ietf.org/html/rfc5842#section-7.1
  13. * @see https://tools.ietf.org/html/rfc5842#section-7.2
  14. * @see https://tools.ietf.org/html/rfc6585#section-3
  15. * @see https://tools.ietf.org/html/rfc6585#section-4
  16. * @see https://tools.ietf.org/html/rfc6585#section-5
  17. * @see https://tools.ietf.org/html/rfc6585#section-6
  18. * @see https://tools.ietf.org/html/rfc7231#section-6
  19. * @see https://tools.ietf.org/html/rfc7238#section-3
  20. * @see https://tools.ietf.org/html/rfc7725#section-3
  21. * @see https://tools.ietf.org/html/rfc7540#section-9.1.2
  22. * @see https://tools.ietf.org/html/rfc8297#section-2
  23. * @see https://tools.ietf.org/html/rfc8470#section-7
  24. * Usage:
  25. *
  26. * <code>
  27. * class ResponseFactory implements StatusCodeInterface
  28. * {
  29. * public function createResponse($code = self::STATUS_OK)
  30. * {
  31. * }
  32. * }
  33. * </code>
  34. */
  35. interface StatusCodeInterface
  36. {
  37. // Informational 1xx
  38. const STATUS_CONTINUE = 100;
  39. const STATUS_SWITCHING_PROTOCOLS = 101;
  40. const STATUS_PROCESSING = 102;
  41. const STATUS_EARLY_HINTS = 103;
  42. // Successful 2xx
  43. const STATUS_OK = 200;
  44. const STATUS_CREATED = 201;
  45. const STATUS_ACCEPTED = 202;
  46. const STATUS_NON_AUTHORITATIVE_INFORMATION = 203;
  47. const STATUS_NO_CONTENT = 204;
  48. const STATUS_RESET_CONTENT = 205;
  49. const STATUS_PARTIAL_CONTENT = 206;
  50. const STATUS_MULTI_STATUS = 207;
  51. const STATUS_ALREADY_REPORTED = 208;
  52. const STATUS_IM_USED = 226;
  53. // Redirection 3xx
  54. const STATUS_MULTIPLE_CHOICES = 300;
  55. const STATUS_MOVED_PERMANENTLY = 301;
  56. const STATUS_FOUND = 302;
  57. const STATUS_SEE_OTHER = 303;
  58. const STATUS_NOT_MODIFIED = 304;
  59. const STATUS_USE_PROXY = 305;
  60. const STATUS_RESERVED = 306;
  61. const STATUS_TEMPORARY_REDIRECT = 307;
  62. const STATUS_PERMANENT_REDIRECT = 308;
  63. // Client Errors 4xx
  64. const STATUS_BAD_REQUEST = 400;
  65. const STATUS_UNAUTHORIZED = 401;
  66. const STATUS_PAYMENT_REQUIRED = 402;
  67. const STATUS_FORBIDDEN = 403;
  68. const STATUS_NOT_FOUND = 404;
  69. const STATUS_METHOD_NOT_ALLOWED = 405;
  70. const STATUS_NOT_ACCEPTABLE = 406;
  71. const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
  72. const STATUS_REQUEST_TIMEOUT = 408;
  73. const STATUS_CONFLICT = 409;
  74. const STATUS_GONE = 410;
  75. const STATUS_LENGTH_REQUIRED = 411;
  76. const STATUS_PRECONDITION_FAILED = 412;
  77. const STATUS_PAYLOAD_TOO_LARGE = 413;
  78. const STATUS_URI_TOO_LONG = 414;
  79. const STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
  80. const STATUS_RANGE_NOT_SATISFIABLE = 416;
  81. const STATUS_EXPECTATION_FAILED = 417;
  82. const STATUS_IM_A_TEAPOT = 418;
  83. const STATUS_MISDIRECTED_REQUEST = 421;
  84. const STATUS_UNPROCESSABLE_ENTITY = 422;
  85. const STATUS_LOCKED = 423;
  86. const STATUS_FAILED_DEPENDENCY = 424;
  87. const STATUS_TOO_EARLY = 425;
  88. const STATUS_UPGRADE_REQUIRED = 426;
  89. const STATUS_PRECONDITION_REQUIRED = 428;
  90. const STATUS_TOO_MANY_REQUESTS = 429;
  91. const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
  92. const STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
  93. // Server Errors 5xx
  94. const STATUS_INTERNAL_SERVER_ERROR = 500;
  95. const STATUS_NOT_IMPLEMENTED = 501;
  96. const STATUS_BAD_GATEWAY = 502;
  97. const STATUS_SERVICE_UNAVAILABLE = 503;
  98. const STATUS_GATEWAY_TIMEOUT = 504;
  99. const STATUS_VERSION_NOT_SUPPORTED = 505;
  100. const STATUS_VARIANT_ALSO_NEGOTIATES = 506;
  101. const STATUS_INSUFFICIENT_STORAGE = 507;
  102. const STATUS_LOOP_DETECTED = 508;
  103. const STATUS_NOT_EXTENDED = 510;
  104. const STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511;
  105. }