Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: client proxy authorization issue #8978

gopherbot opened this issue Oct 22, 2014 · 4 comments


None yet
3 participants
Copy link

commented Oct 22, 2014

by guohongqiao:

I am using go1.3.3, and test with the following code, it works well

however, when I try to use the basic authorization of the client package with the
following code, 

the proxy server(squid3) will prompt "407 Proxy Authentication Required"

the difference between the two snipet is the http requet header. 
The first use "Proxy-Authorization", and the second use 
"Authorization" in the method SetBasicAuth.

there is also an issue that http client discard the http headers(including
Proxy-Authorization) when the server redirect with 301.

This comment has been minimized.

Copy link

commented Oct 22, 2014

Comment 1:

Labels changed: added repo-main, release-none.


This comment has been minimized.

Copy link

commented Oct 23, 2014

Comment 2:

This bug report is a little confusing but I'll take a guess at understanding:
I think the play snippets provided are wrong: the way to set Proxy-Authorization (a
hop-by-hop header, not an end-to-end header) is by setting the net/http.Transport.Proxy
hook to return a proxy URL with the User and Password fields set.  Then the transport.go
code adds the Proxy-Authorization header for you on each request.  You don't do it by
And your other bug in the final sentence is covered by issue #4800

Status changed to Invalid.


This comment has been minimized.

Copy link

commented Oct 24, 2014

Comment 3 by guohongqiao:

When we use a proxy requiring authorization, the authorization(user/password) should be
for the proxy server, not for the end application.
Here is a http proxy built with squid3:
or you can test with other http proxies.
The following code is from python project "requests', requests provider two
HTTPBasicAuth and HTTPProxyAuth

This comment has been minimized.

Copy link

commented Oct 28, 2014

Comment 4 by guohongqiao:

I have tried the proxy with Chrome + SwitchySharp, and monitor the network with
Wireshark,  and find SwitchySharp use the http header  "Proxy-Authorization"

@golang golang locked and limited conversation to collaborators Jun 25, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.