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

[question][feature] Add custom CONNECT header for proxy? #559

Closed
Fenny opened this issue Dec 10, 2019 · 2 comments
Closed

[question][feature] Add custom CONNECT header for proxy? #559

Fenny opened this issue Dec 10, 2019 · 2 comments
Labels

Comments

@Fenny
Copy link

Fenny commented Dec 10, 2019

Hello,

There are many proxy providers that use custom headers to authenticate or to rotate the proxy ip.
I'm wondering if I add the following code to proxy.go Line 41-42 would that be the right way to do it?

connectHeader.Set("custom-proxy-header", "hi mom")

If so, maybe we could add this as an extra feature?

dialer := websocket.Dialer{
  HandshakeTimeout: 10 * time.Second,
  Proxy: http.ProxyURL(&url.URL{
    Scheme:     "http",
    Host: 	"127.0.0.1:16969",
    Path: 	"/",
  }),
  ProxyHeaders: map[string]string{
    "custom-proxy-header": "hi mom",
  },
}

Thank you for all the help, I'm new to GO and the community is awesome :)

Duplicate Issue 479

@Fenny Fenny added the question label Dec 10, 2019
@Fenny Fenny changed the title [question] Add custom header for proxy connect? [question] Add custom CONNECT header for proxy? Dec 10, 2019
@Fenny Fenny changed the title [question] Add custom CONNECT header for proxy? [question][feature] Add custom CONNECT header for proxy? Dec 10, 2019
@ghost
Copy link

ghost commented Dec 10, 2019

The field should be ProxyConnectHeader http.Header to match the net/http Transport field. Other than that, this is a duplicate of 479.

@Fenny
Copy link
Author

Fenny commented Dec 10, 2019

Untill this feature gets properly implemented into the main branch, you can use my version.
https://github.com/fenny/websocket

dialer := websocket.Dialer{
  Proxy: http.ProxyURL(&url.URL{
    Scheme: "http",
    Host: "127.0.0.1:6969",
    Path: "/",
  }),
  ProxyConnectHeaders: map[string]string{
    "Proxy-Auth": "user:pass",
    "Proxy-Geo":  "EU",
  },
}

@Fenny Fenny closed this as completed Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant