status.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. """
  2. Descriptive HTTP status codes, for code readability.
  3. See RFC 2616 - https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  4. And RFC 6585 - https://tools.ietf.org/html/rfc6585
  5. And RFC 4918 - https://tools.ietf.org/html/rfc4918
  6. """
  7. def is_informational(code):
  8. return 100 <= code <= 199
  9. def is_success(code):
  10. return 200 <= code <= 299
  11. def is_redirect(code):
  12. return 300 <= code <= 399
  13. def is_client_error(code):
  14. return 400 <= code <= 499
  15. def is_server_error(code):
  16. return 500 <= code <= 599
  17. HTTP_100_CONTINUE = 100
  18. HTTP_101_SWITCHING_PROTOCOLS = 101
  19. HTTP_200_OK = 200
  20. HTTP_201_CREATED = 201
  21. HTTP_202_ACCEPTED = 202
  22. HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203
  23. HTTP_204_NO_CONTENT = 204
  24. HTTP_205_RESET_CONTENT = 205
  25. HTTP_206_PARTIAL_CONTENT = 206
  26. HTTP_207_MULTI_STATUS = 207
  27. HTTP_208_ALREADY_REPORTED = 208
  28. HTTP_226_IM_USED = 226
  29. HTTP_300_MULTIPLE_CHOICES = 300
  30. HTTP_301_MOVED_PERMANENTLY = 301
  31. HTTP_302_FOUND = 302
  32. HTTP_303_SEE_OTHER = 303
  33. HTTP_304_NOT_MODIFIED = 304
  34. HTTP_305_USE_PROXY = 305
  35. HTTP_306_RESERVED = 306
  36. HTTP_307_TEMPORARY_REDIRECT = 307
  37. HTTP_308_PERMANENT_REDIRECT = 308
  38. HTTP_400_BAD_REQUEST = 400
  39. HTTP_401_UNAUTHORIZED = 401
  40. HTTP_402_PAYMENT_REQUIRED = 402
  41. HTTP_403_FORBIDDEN = 403
  42. HTTP_404_NOT_FOUND = 404
  43. HTTP_405_METHOD_NOT_ALLOWED = 405
  44. HTTP_406_NOT_ACCEPTABLE = 406
  45. HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407
  46. HTTP_408_REQUEST_TIMEOUT = 408
  47. HTTP_409_CONFLICT = 409
  48. HTTP_410_GONE = 410
  49. HTTP_411_LENGTH_REQUIRED = 411
  50. HTTP_412_PRECONDITION_FAILED = 412
  51. HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413
  52. HTTP_414_REQUEST_URI_TOO_LONG = 414
  53. HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415
  54. HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416
  55. HTTP_417_EXPECTATION_FAILED = 417
  56. HTTP_418_IM_A_TEAPOT = 418
  57. HTTP_422_UNPROCESSABLE_ENTITY = 422
  58. HTTP_423_LOCKED = 423
  59. HTTP_424_FAILED_DEPENDENCY = 424
  60. HTTP_426_UPGRADE_REQUIRED = 426
  61. HTTP_428_PRECONDITION_REQUIRED = 428
  62. HTTP_429_TOO_MANY_REQUESTS = 429
  63. HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431
  64. HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS = 451
  65. HTTP_500_INTERNAL_SERVER_ERROR = 500
  66. HTTP_501_NOT_IMPLEMENTED = 501
  67. HTTP_502_BAD_GATEWAY = 502
  68. HTTP_503_SERVICE_UNAVAILABLE = 503
  69. HTTP_504_GATEWAY_TIMEOUT = 504
  70. HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505
  71. HTTP_506_VARIANT_ALSO_NEGOTIATES = 506
  72. HTTP_507_INSUFFICIENT_STORAGE = 507
  73. HTTP_508_LOOP_DETECTED = 508
  74. HTTP_509_BANDWIDTH_LIMIT_EXCEEDED = 509
  75. HTTP_510_NOT_EXTENDED = 510
  76. HTTP_511_NETWORK_AUTHENTICATION_REQUIRED = 511