Python Falcon 状态代码
默认情况下,HTTP服务器对客户端请求的响应是有200 OK状态。Falcon提供了自己的状态常量列表,以提高便利性和可读性。
例如,200 OK状态代码的表示方法是。
这些预定义的Falcon常量可以避免打字错误,并减少准备响应时必须创建的字符串对象的数量。然而,从Falcon 3.0版本开始,也允许使用裸 int 代码。
对于ASGI应用,同样的状态代码也适用。
Falcon库中定义的一些状态代码列举如下
信息性代码
-
http_continue = http_100
-
http_switching_protocols = http_101
-
http_processing = http_102
成功状态代码
-
http_ok = http_200
-
http_created = http_201
-
http_accepted = http_202
-
http_non_authoritative_information = http_203
-
http_no_content = http_204
-
http_reset_content = http_205
-
http_partial_content = http_206
-
http_multi_status = http_207
-
http_already_reported = http_208
-
http_im_used = http_226
重定向错误代码
-
http_multiple_choices = http_300
-
http_moved_permanently = http_301
-
http_found = http_302
-
http_see_other = http_303
-
http_not_modified = http_304
-
http_use_proxy = http_305
-
http_temporary_redirect = http_307
-
http_permanent_redirect = http_308
客户端错误代码
-
http_bad_request = http_400
-
HTTP_UNAUTHORIZED = HTTP_401 # “未认证”
-
http_payment_required = http_402
-
HTTP_FORBIDDEN = HTTP_403 # “未经授权”
-
http_not_found = http_404
-
http_method_not_allowed = http_405
-
http_not_acceptable = http_406
-
http_proxy_authentication_required = http_407
-
http_request_timeout = http_408
-
http_conflict = http_409
服务器错误代码
-
http_internal_server_error = http_500
-
http_not_implemented = http_501
-
http_bad_gateway = http_502
-
http_service_unavailable = http_503
-
http_gateway_timeout = http_504
-
http_http_version_not_supported = http_505
-
http_insufficient_storage = http_507
-
http_loop_detected = http_508
-
http_network_authentication_required = http_511