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: returned typed error when proxy connection fails #16997

Closed
tcmichael opened this issue Sep 6, 2016 · 2 comments

Comments

Projects
None yet
5 participants
@tcmichael
Copy link

commented Sep 6, 2016

Please answer these questions before submitting your issue. Thanks!

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

$go version
go version go1.6.2 darwin/amd64

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.6.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.6.2/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

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

func main() {
    proxy := "http://2.2.2.2:80"
    tr := &http.Transport{
        Proxy: func(*http.Request) (*url.URL, error) {
            return url.Parse(proxy)
        },
        Dial: (&net.Dialer{Timeout: 500 * time.Millisecond}).Dial,
    }
    c := http.Client{Transport: tr}
    req, _ := http.NewRequest("GET", "http://golang.org", nil)
    _, err := c.Do(req)
    uerr, ok := err.(*url.Error)
    if ok {
        nerr, ok := uerr.Err.(*net.OpError)
        fmt.Println(ok, nerr)
    }
}

What did you expect to see?

true, http://2.2.2.2:80: dial tcp 2.2.2.2:80: i/o timeout".

I could find the Op of the error would be dial.
net/http/transport.go: 765 "err = fmt.Errorf("http: error connecting to proxy %s: %v", cm.proxyURL, err)".
That rewrites the error, and the details of the error are missing

What did you see instead?

false <nil>

@bradfitz bradfitz changed the title the error of connecting to proxy is not an assertion error net/error: returned typed error when proxy connection fails Sep 6, 2016

@bradfitz bradfitz added the help wanted label Sep 6, 2016

@bradfitz bradfitz added this to the Go1.8Maybe milestone Sep 6, 2016

@mikioh mikioh changed the title net/error: returned typed error when proxy connection fails net/http: returned typed error when proxy connection fails Oct 4, 2016

@asticode

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2016

Hey guys, if everyone is OK with that I'd like to take a stab at it

@gopherbot

This comment has been minimized.

Copy link

commented Oct 8, 2016

CL https://golang.org/cl/30750 mentions this issue.

@quentinmit quentinmit added the NeedsFix label Oct 10, 2016

@gopherbot gopherbot closed this in 61ffec4 Oct 31, 2016

@golang golang locked and limited conversation to collaborators Oct 31, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.