mirror of
https://github.com/snail007/goproxy.git
synced 2026-04-27 16:35:49 +03:00
[PR #88] [CLOSED] HTTP Basic 认证失败返回的 WWW-Authenticate 更正为 Proxy-Authenticate #517
Labels
No labels
TODO
bug
duplicate
enhancement
good first issue
help wanted
helpful
invalid
need-confirm
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/goproxy#517
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/snail007/goproxy/pull/88
Author: @moonfruit
Created: 5/23/2018
Status: ❌ Closed
Base:
master← Head:http-proxy-auth📝 Commits (1)
fe7c585HTTP Basic 认证失败返回的 WWW-Authenticate 更正为 Proxy-Authenticate📊 Changes
1 file changed (+2 additions, -2 deletions)
View changed files
📝
utils/structs.go(+2 -2)📄 Description
使用其它 HTTP 代理服务器(如 squid)时,若开启 HTTP Basic 用户认证,则浏览器如 Chrome 在不指定用户名密码的情况下使用代理服务器访问网页时,会弹出一个认证窗口,要求用户输入。但是现在 goproxy 作为代理服务器时,则直接返回 Unauthorized。在配合一些可以自动输入代理用户名密码的浏览器插件(如 SwitchyOmega)时,这些插件无法正常工作。
在进行了一定的调查以后,发现 goproxy 在 HTTP Basic 认证失败后返回给客户端的是状态码 407 和 HTTP 头 WWW-Authenticate。在查看过 Mozilla 的 HTTP 头说明文档后可以发现,WWW-Authenticate 通常是和状态码 401 一起使用的,代表直接访问网页时要求认证。而在 HTTP 代理服务器中应该使用的是状态码 407 和 Proxy-Authenticate。
在将 WWW-Authenticate 更改为 Proxy-Authenticate 后,浏览器使用 goproxy 和其它代理服务器时的行为一致了,浏览器代理插件也正常工作了。
我顺便改了下返回给客户端的状态码描述信息,401 是 Unauthorized,而 407 是 Proxy Authentication Required。
我将这部分代码提交了,希望能合并到 goproxy 的主线上,谢谢!
以下是参考的 Mozilla 的文档:
WWW-Authenticate
Proxy-Authenticate
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.