HTTP Status Codes missing some IANA/industry-standard values
#23,458 opened on 2022年10月12日
Repository metrics
- Stars
- (27,997 stars)
- PR merge metrics
- (平均マージ 8d) (30d で 378 merged PRs)
説明
Title: The HTTP status code definitions are missing some well-know/standard values
Description:
Testing the
request_handle:respondLua function with various status codes, I find that the status text for the following codes is set to "Unknown" instead of the correct value:
- 102: "Processing", # see RFC 2518
- 103: "Early Hints", # see RFC 8297
- 306: "Switch Proxy", # Switch Proxy (now unused)
- 418: "I'm a teapot", # see RFC 2324 (now unused)
- 425: "Too Early", # see RFC 8470
- 449: "Retry With", # proprietary MS extension
- 451: "Unavailable For Legal Reasons"
With the other status codes, like 200 or 301, the correct status text is return in the response ("OK" or "Moved Permanently", respectively). With the status codes listed above, the status text is "Unknown" instead of the IANA/industry values.
Searching the source code, it appears that these codes are just missing from the various HTTP status definitions.
All of these, with the possible exceptions of deprecated/non-standard 306, 418, and 449, should be added to the various lists of HTTP status codes in the Envoy source.
Sources:
- IANA list reference in Envoy docs
- werkzeug Python lib
- https://github.com/envoyproxy/envoy/blob/v1.23.1/bazel/external/http_parser/http_parser.h
Source code locations
10:24:18 envoy$ grep -ril "moved.*permanently" *
api/envoy/config/route/v3/route_components.proto
api/envoy/type/v3/http_status.proto
api/envoy/type/http_status.proto
api/envoy/api/v2/route/route_components.proto
bazel/external/http_parser/http_parser.h
envoy/http/codes.h
source/common/http/codes.cc
source/common/router/config_utility.cc
source/common/router/config_impl.h
test/extensions/filters/http/ext_proc/ext_proc_grpc_fuzz_helper.cc
test/common/http/codes_test.cc
test/common/router/config_impl_test.cc
test/common/router/router_test.cc
10:24:26 envoy$
vs.
10:24:26 envoy$ grep -ril "unavailable.*for.*legal.*reasons" *
bazel/external/http_parser/http_parser.h
10:25:00 envoy$
Repro steps:
Try the Lua code:
request_handle:respond(
{[":status"] = status_code}, "")
with the known status codes. Aside from 500-504, which appear to be caught as other errors, all of the Werkzeug/IANA values provide the correct status text except for those lists above, which say "Unknown"
Or just grep as shown above to check for the texts of these codes.
As a potential work-around, I tried using a string of "status_code status_text" in request_handle:response but that doesn't work and, instead, responds with 404 Not Found.