HTTP状态代码可以具有小数值吗?

发布于 2025-02-05 18:45:44 字数 535 浏览 2 评论 0原文

在.NET Core WebAPI中,是否可以选择使用小数示例401.2、401.3等引入HTTP状态代码,例如在IIS中进行的方式?

使用小数为小数的HTTP状态代码是更好的练习吗?如果不是这样,为什么在IIS中引入它?

http substatus代码

In .net core webapi, is there option to introduce HTTP status code with decimals example 401.2, 401.3 etc., like how it is been done in IIS?

Is it better practice to have HTTP status code with decimals? if it is not, why it is been introduced in IIS?

HTTP sub-status codes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮光之海 2025-02-12 18:45:44

HTTP状态代码可以具有十进制值吗?

最新的HTTP规范(RFC 9110)说

响应的状态代码是三位数整数代码。...所有有效的状态代码均在100至599的范围内,包括。

因此,否 - 具有小数值的状态代码是 无效的。

状态代码为整数的约束可以追溯到RFC 1945(1996)


为什么在IIS中引入它?

正如较早的一个问题所讨论的那样:

iis定义了替代方案,以帮助在相同定义的状态代码中区分案例,以进行调试目的。这些不是在HTTP响应中的电线上发送的;正如其他人指出的那样,这是一个整数。如果配置,它们可能出现在响应实体中(默认情况下,仅适用于在同一主机上运行的客户端),并且在“ SC-Substatus”列下的W3C日志中登录。 - Mike Bishop,2016-08-09

Does HTTP status code can have decimal values?

The most recent HTTP specification (RFC 9110) says

The status code of a response is a three-digit integer code.... All valid status codes are within the range of 100 to 599, inclusive.

So, no - a status code with a decimal value is not valid.

The constraint that status codes be integers dates back to RFC 1945 (1996)


why it is been introduced in IIS?

As discussed in an earlier question:

IIS defines substatuses to help differentiate cases within the same defined status code for debugging purposes. These aren't sent on the wire in the HTTP response; as others have noted, that's an integer. They may appear in the response entity if configured (by default, only for clients running on the same host), and they're logged in the W3C log under the "sc-substatus" column. -- Mike Bishop, 2016-08-09

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文