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
Closed

net/http: returned typed error when proxy connection fails #16997

tcmichael opened this issue Sep 6, 2016 · 2 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@tcmichael
Copy link

tcmichael 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 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
Copy link
Contributor

asticode commented Oct 8, 2016

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

@gopherbot
Copy link

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

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 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.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants