Skip to content

net/http: Transport.Proxy fails with HTTPS #73010

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

Closed
3052 opened this issue Mar 23, 2025 · 1 comment
Closed

net/http: Transport.Proxy fails with HTTPS #73010

3052 opened this issue Mar 23, 2025 · 1 comment
Labels
BugReport Issues describing a possible bug in the Go implementation.

Comments

@3052
Copy link

3052 commented Mar 23, 2025

Go version

go version go1.24.0 windows/amd64

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\Steven\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\Steven\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Windows\TEMP\go-build1974498014=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=NUL
set GOMODCACHE=C:\Users\Steven\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Steven\go
set GOPRIVATE=
set GOPROXY=direct
set GOROOT=D:\go
set GOSUMDB=off
set GOTELEMETRY=off
set GOTELEMETRYDIR=C:\Users\Steven\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.0
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

this code works fine:

package main

import (
   "net/http"
   "net/url"
   "os"
)

func main() {
   var port http.Transport
   http.DefaultClient.Transport = &port
   get()
   port.Proxy = http.ProxyURL(&url.URL{
      Scheme: "http", Host: "127.0.0.1:8080",
   })
   get()
}

func get() error {
   resp, err := http.Get("http://httpbingo.org/get")
   if err != nil {
      return err
   }
   return resp.Write(os.Stdout)
}

but if I use HTTPS instead the proxy is not used:

resp, err := http.Get("https://httpbingo.org/get")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation.
Projects
None yet
Development

No branches or pull requests

2 participants