HTTP状态码401

title

HTTP 401是HTTP状态码的一种,表示客户端未经身份验证,无权访问请求的资源。当客户端尝试访问需要身份验证的资源时,服务器会返回HTTP 401错误。

HTTP 401错误通常包含一个WWW-Authenticate头,该头指示客户端必须提供适当的凭据才能访问请求的资源。以下是一个HTTP 401错误的示例响应:

HTTP/1.1 401 Unauthorized
Date: Fri, 05 Mar 2021 05:14:20 GMT
Server: Apache/2.4.38 (Debian)
WWW-Authenticate: Basic realm="Restricted Area"
Content-Type: text/html; charset=iso-8859-1
Content-Length: 381

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you are authorized to access the document requested.<br />
Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.</p>
<hr>
<address>Apache/2.4.38 (Debian) Server at example.com Port 80</address>
</body></html>

在此响应中,服务器返回HTTP 401错误,并在WWW-Authenticate头中指示客户端必须提供适当的凭据才能访问请求的资源。客户端可以根据此信息来提供适当的凭据并重新发送请求。

HTTP 401错误通常是由于客户端未提供正确的凭据或凭据无效而引起的。服务器需要身份验证以保护资源免受未经授权的访问,因此客户端必须提供适当的凭据才能访问受保护的资源。

powered by Gitbook© 2023 编外计划 | 最后修改: 2023-11-24 03:36:58

results matching ""

    No results matching ""