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

Closed
gopherbot opened this issue Oct 22, 2014 · 4 comments
Closed

net/http: client proxy authorization issue #8978

gopherbot opened this issue Oct 22, 2014 · 4 comments

Comments

@gopherbot
Copy link

by guohongqiao:

I am using go1.3.3, and test with the following code, it works well
http://play.golang.org/p/ue0YHoz-3e

however, when I try to use the basic authorization of the client package with the
following code,
http://play.golang.org/p/SKk2oiQgJj 

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.
@ianlancetaylor
Copy link
Contributor

Comment 1:

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

@bradfitz
Copy link
Contributor

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
hand.
And your other bug in the final sentence is covered by issue #4800

Status changed to Invalid.

@gopherbot
Copy link
Author

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:
IP:199.193.255.39 
Port:43543
user:golang
password:golang123
or you can test with other http proxies.
The following code is from python project "requests', requests provider two
HTTPBasicAuth and HTTPProxyAuth
https://github.com/kennethreitz/requests/blob/master/requests/auth.py

@gopherbot
Copy link
Author

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.
Projects
None yet
Development

No branches or pull requests

3 participants