Description
What version of Go are you using (go version
)?
go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN="/Users/roman/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/roman/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dr/8l_15wcn2_bfj47vdvsm4q3w0000gn/T/go-build185245545=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
It's very simple code :).
I try to http.Get("http://google.com")
and receive error: Get http://google.com: read tcp 10.9.58.79:51401->172.217.5.238:80: read: connection reset by peer
. Domain is no matter, it's not working for all domains :(
Here is a simple example of code:
package main
import (
"net/http"
)
func main() {
http.Get("http://google.com")
}
After several experiments I came to the conclusion that error receives only on http request, on https works fine like this http.Get("https://google.com")
and this bug receives only on macOS ! I tried on linux and everything worked as it should. My system is:
System: macOS 10.13.1 (17B1003)
Kernel: Darwin 17.2.0
And by the end of my experiments, I noticed that if I add the User-Agent header (empty or not empty, it's not matter), everything works fine like this:
package main
import (
"net/http"
"fmt"
)
func main() {
req, err := http.NewRequest("GET", "http://google.com/", nil)
if err != nil {
panic(err)
}
req.Header.Set("User-Agent", "")
fmt.Println(http.DefaultClient.Do(req))
}
What did you expect to see?
result of request
What did you see instead?
error