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: add customization of proxy CONNECT requests #15027

AlmogBaku opened this issue Mar 30, 2016 · 5 comments

net/http: add customization of proxy CONNECT requests #15027

AlmogBaku opened this issue Mar 30, 2016 · 5 comments


Copy link

@AlmogBaku AlmogBaku commented Mar 30, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
  2. What operating system and processor architecture are you using (go env)?
    darwin amd64 [os x]
  3. What did you do?
    I tried to use Proxy with a Bearer authentication method.
  4. What did you expect to see?
    Allow other authentication method than Basic HTTP
  5. What did you see instead?
    Proxy authentication is limited to Basic-HTTP-Authentication only, with user & password:
  6. Suggestion
    • url.URL should allow custom authentication such as bearer
    • url.URL should provide a method that returns the "authentication header value", and do the base64 etc.
Copy link

@bradfitz bradfitz commented Mar 30, 2016

This proposal is a little confused. It's proposing modifications to url.URL, but talking about net/http stuff. I think you're probably looking for and friends. In general, I think everything you need is already on somewhere.

Let's discuss your actual needs on the mailing list before jumping to proposals. See

@bradfitz bradfitz closed this Mar 30, 2016
@bradfitz bradfitz changed the title http/transport: add custom proxy authentication net/http: add customization of proxy CONNECT requests Mar 30, 2016
@bradfitz bradfitz reopened this Mar 30, 2016
@bradfitz bradfitz added this to the Unplanned milestone Mar 30, 2016
Copy link

@mattn mattn commented Mar 31, 2016

Well, I don't make sure but this seems not change of net/url. And maybe simply implementation of Transport.Proxy.

package main

import (

func main() {
    token := "blur"
    http.DefaultClient.Transport.(*http.Transport).Proxy = func(r *http.Request) (*url.URL, error) {
        r.Header.Add("Authorization", "Bearer " + token)
        return r.URL, nil
Copy link

@AlmogBaku AlmogBaku commented Mar 31, 2016

@mattn As I mentioned in the mailing-list, the problem is that when you do https, the CONNECT request wraps the original request, and there is no way to attach headers to the CONNECT req

Copy link

@bradfitz bradfitz commented Dec 15, 2016

@bradfitz bradfitz closed this Dec 15, 2016
@golang golang locked and limited conversation to collaborators Dec 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants