HTTPQUERY
English

511 Network Authentication Required

用法

511 Network Authentication Required 状态码告知 HTTP 客户端在被授予网络访问权限之前需要先登录。强制门户(captive portal)的一个例子是酒店门户,它为住客授予对非公开 Wi-Fi 服务的访问权限。

511 Network Authentication Required 状态码向 HTTP 客户端表明,该响应并非来自源站服务器,而是来自要求进行身份验证的网络守门方(gatekeeper)。

SEO 影响

搜索引擎对 511 的处理与其他 5xx 服务器错误相同。持续的失败会降低抓取速率,并最终将受影响的 URL 从索引中移除。

示例

HTTP 客户端请求某个资源,服务器返回 511 Network Authentication Required 状态码,因为客户端必须先完成身份验证,才能被授予常规的网络访问权限。

请求

GET / HTTP/1.1
Host: example.com

响应

HTTP/1.1 511 Network Authentication Required
Content-Type: text/html; charset=UTF-8
Content-Length: 218

<html>
  <head>
    <title>Network Authentication Required</title>
  </head>
  <body>
    <p>Before accessing this service,
    <a href="https://login.example.re/">sign in
    </a> to the network.</p>
  </body>
</html>

如何修复

网络在授予互联网访问权限之前要求进行身份验证。一个强制门户正在拦截 HTTP 流量,并在登录完成之前返回 511。

对于终端用户:

对于自动化客户端和应用程序:

对于返回 511 的网络运营方:

代码参考

.NET

HttpStatusCode.NetworkAuthenticationRequired

Rust

http::StatusCode::NETWORK_AUTHENTICATION_REQUIRED

Rails

:network_authentication_required

Go

http.StatusNetworkAuthenticationRequired

Symfony

Response::HTTP_NETWORK_AUTHENTICATION_REQUIRED

Python3.5+

http.HTTPStatus.NETWORK_AUTHENTICATION_REQUIRED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_NETWORK_AUTHENTICATION_REQUIRED

Angular

@angular/common/http/HttpStatusCode.NetworkAuthenticationRequired