This is a small peace of code:
//resp, err := http.Get("https://alfabank.ru")
resp, err := http.Get("https://google.com")
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
fmt.Println(string(body))
It works fine with Google, but hangs on alfabank (try to uncomment first line and comment second). I can't figure out on which side this problem :( But, for example,
curl https://alfabank.ru
works fine.
So, I think, that the problem in Golang client.
I tried to use tcpdump and see infinite traffic between my machine and remote server.
Could you help me to figure out the problem?
UPDATE: following the advice from comments
Ok, curl sends this headers:
> GET / HTTP/1.1
> Host: alfabank.ru
> User-Agent: curl/7.54.0
> Accept: */*
So, I tried
req, err := http.NewRequest(http.MethodGet, "http://alfabank.ru", nil)
if err != nil {
log.Fatalln(err)
}
req.Header.Add("Accept", "*/*")
req.Header.Add("User-Agent", "curl/7.54.0")
client := http.Client{}
resp, err := client.Do(req)
It doesn't solve the problem.