首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >代理授权失败的HTTP响应码

代理授权失败的HTTP响应码
EN

Stack Overflow用户
提问于 2013-02-13 17:08:43
回答 2查看 3.6K关注 0票数 4

代理授权失败的HTTP响应代码应该是什么?我知道407是请求代理授权的响应码。但是,一旦客户端将身份验证信息发送到代理,并且如果它是不正确的,代理应该返回什么?如果它返回401响应码,那么客户端如何识别它是代理上的身份验证失败,而不是终端资源上的身份验证失败?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-02-13 19:45:10

好吧,如果一个受401保护的资源出现授权失败,服务器会简单地返回另一个401:

代码语言:javascript
复制
Request URL:https://mysite.com/myresource/
Request Method:GET
Status Code:401 Authorization Required

Request Headers

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Authorization:Digest username="gjggj", realm="apps", nonce="75602afa895d26f9796f3c9174cf83f3", uri="/misc/apps/", algorithm=MD5, response="9e113b10d3e95b590bdef0fc7c7c617b", qop=auth, nc=00000001, cnonce="61f73b73f6b33ea2"
Cache-Control:max-age=0
Connection:keep-alive
Host:game-point.net
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17

Response Headers

Cache-Control:no-cache
Connection:close
Content-Length:534
Content-Type:text/html
Date:Wed, 13 Feb 2013 11:07:26 GMT
Pragma:no-cache
Server:Cherokee/1.0.8 (Debian GNU/Linux)
WWW-Authenticate:Digest realm="apps", nonce="75602afa895d26f9796f3c9174cf83f3", qop="auth", algorithm="MD5"

所以我要说的是,处理407授权失败的方法是让服务器响应407状态代码,尽管浏览器已经发送了授权信息;这表明代理仍然需要授权,并暗示授权失败只是因为您仍然获得407状态代码。

票数 3
EN

Stack Overflow用户

发布于 2013-11-29 17:41:54

来自官方机构:

http://www.ietf.org/rfc/rfc2617.txt

代码语言:javascript
复制
If the origin server does not wish to accept the credentials sent
with a request, it SHOULD return a 401 (Unauthorized) response. The
response MUST include a WWW-Authenticate header field containing at
least one (possibly new) challenge applicable to the requested
resource. If a proxy does not accept the credentials sent with a
request, it SHOULD return a 407 (Proxy Authentication Required). The
response MUST include a Proxy-Authenticate header field containing a
(possibly new) challenge applicable to the proxy for the requested
resource.
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14849923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档