Skip to content

Support custom HTTP headers for CONNECT proxy request #479

@aus

Description

@aus

When an HTTP proxy is used, there is no way to customize the headers in the initial CONNECT request. In some situations, a HTTP proxy may require certain User-Agents or other headers. golang added support for this in net/http in 1.8. The golang issue is documented here with support added in 1.8 as documented here.

Note, this is not the same as providing a requestHeader to Conn.NewClient or Dialer.Dial. These headers are only present after the initial CONNECT request to the HTTP proxy.

Activity

Fenny

Fenny commented on Dec 9, 2019

@Fenny

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",
  },
}
linked a pull request that will close this issue on Jun 29, 2020
added a commit that references this issue on Sep 11, 2020
moved this to 🏗 In progress in Gorilla Web Toolkiton Jul 23, 2023
michel-laterman

michel-laterman commented on Jun 3, 2025

@michel-laterman

@AlexVulaj, I'm interested in moving this issue forward. There's an implementation PR that looks like it's no longer maintained (#605). What should the approach be when it comes to getting the PR in a mergable state?

EDIT: I went ahead and created another PR #988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    🏗 In progress

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @elithrar@aus@coreydaley@Fenny@michel-laterman

      Issue actions

        Support custom HTTP headers for CONNECT proxy request · Issue #479 · gorilla/websocket