[PR #88] [CLOSED] HTTP Basic 认证失败返回的 WWW-Authenticate 更正为 Proxy-Authenticate #517

Closed
opened 2026-02-27 23:17:17 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/snail007/goproxy/pull/88
Author: @moonfruit
Created: 5/23/2018
Status: Closed

Base: masterHead: http-proxy-auth


📝 Commits (1)

  • fe7c585 HTTP 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.

## 📋 Pull Request Information **Original PR:** https://github.com/snail007/goproxy/pull/88 **Author:** [@moonfruit](https://github.com/moonfruit) **Created:** 5/23/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `http-proxy-auth` --- ### 📝 Commits (1) - [`fe7c585`](https://github.com/snail007/goproxy/commit/fe7c585be3e4659b1e12171c40018c76ca907f78) HTTP Basic 认证失败返回的 WWW-Authenticate 更正为 Proxy-Authenticate ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `utils/structs.go` (+2 -2) </details> ### 📄 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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate) [Proxy-Authenticate](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authenticate) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 23:17:17 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/goproxy#517
No description provided.