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

proposal: net/http: increase verbosity of unsuccessful proxy CONNECT request #40873

Closed
maxifom opened this issue Aug 18, 2020 · 1 comment
Closed

Comments

@maxifom
Copy link

maxifom commented Aug 18, 2020

What version of Go are you using (go version)?

$ go version
go version go1.15 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/max/.cache/go-build"
GOENV="/home/max/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/max/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/max/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/max/go/src/www_https_detector/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build124294710=/tmp/go-build -gno-record-gcc-switches"

What did you do?

So in my environment http://antipa.hiblogger.net redirects to https://www.obozrevatel.com/blogs/

When I use direct connect without proxy, its working fine.

With Proxy it got intercepted with 302 (full response in Additional info) to my provider ban page http://blacklist.miralogic.ru and all I see in the error is "Found".

My code
package main

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

func main() {
	// omitted my user and pass for proxy
	u, _ := url.Parse("http://<omitted>:<omitted>@zproxy.lum-superproxy.io:22225")

	c := &http.Client{
		Transport: &http.Transport{
			Proxy:             http.ProxyURL(u),
		},
	}

	_, err := c.Get("http://antipa.hiblogger.net")
	panic(err)
}

What did you expect to see?

I suggest to change the error in

return nil, errors.New(f[1])

and
return nil, errors.New("unknown status code")

from errors.New with Status Text to something more verbose to better understand the nature of the problem (It's a proxy CONNECT error).

Maybe there should be something like net.OpError like in

return &net.OpError{Op: "proxyconnect", Net: "tcp", Err: err}
?

What did you see instead?

Output:

panic: Get "https://www.obozrevatel.com/blogs/": Found

Additional info

Response from CONNECT response (variable resp in dialConn function

func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *persistConn, err error) {
)

{
    "resp": {
        "Status": "302 Found",
        "StatusCode": 302,
        "Proto": "HTTP/1.1",
        "ProtoMajor": 1,
        "ProtoMinor": 1,
        "Header": {
            "Location": "http://blacklist.miralogic.ru",
            "Content-Type": "text/html; charset=utf-8",
            "Content-Length": 146
        },
        "Body": "<omitted>",
        "ContentLength": 146,
        "TransferEncoding": null,
        "Close": false,
        "Trailer": null,
        "Request": {
            "Method": "CONNECT",
            "URL": {
                "Scheme": "",
                "Opaque": "www.obozrevatel.com:443",
                "User": null,
                "Host": "",
                "Path": "",
                "RawPath": "",
                "ForceQuery": false,
                "RawQuery": "",
                "Fragment": "",
                "RawFragment": ""
            },
            "Proto": "",
            "ProtoMajor": 0,
            "ProtoMinor": 0,
            "Header": {
                "Proxy-Authorization": "Basic <omitted>"
            },
            "Body": "<omitted>",
            "GetBody": null,
            "ContentLength": 0,
            "TransferEncoding": null,
            "Close": false,
            "Host": "www.obozrevatel.com:443",
            "Form": null,
            "PostForm": null,
            "MultipartForm": null,
            "Trailer": null,
            "RemoteAddr": "",
            "RequestURI": "",
            "TLS": null,
            "Cancel": null,
            "Response": null,
            "ctx": null
        },
        "TLS": null
    }
}
@maxifom maxifom changed the title net/http: increase verbosity of unsuccessful proxy CONNECT request proposal: net/http: increase verbosity of unsuccessful proxy CONNECT request Aug 18, 2020
@gopherbot gopherbot added this to the Proposal milestone Aug 18, 2020
@ericlagergren
Copy link
Contributor

ericlagergren commented Aug 19, 2020

Duplicate of #38143

@golang golang locked and limited conversation to collaborators Aug 19, 2021
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

4 participants