```
for i := 0; i < 1000; i++ {
var tr *http2.Transport`
if serverCer {
tr = &http2.Transport{
TLSClientConfig: &tls.Config{
RootCAs: pool,
Certificates: []tls.Certificate{cliCrt},
},
}
} else {
tr = &http2.Transport{
TLSClientConfig: &tls.Config{
RootCAs: pool,
Certificates: []tls.Certificate{cliCrt},
InsecureSkipVerify: true,
},
}
}
go client(url, &data, tr)
}
func client(url string, data *[]byte, tr *http2.Transport) {
httpClient := http.Client{Transport: tr}
for i := 0; i < 10; i++ {
fmt.Println("I:", i)
fmt.Println("len:", len(*data))
reader := bytes.NewReader(*data)
if reader == nil {
fmt.Println("reader is nil")
}
req, err := http.NewRequest("POST", url, reader)
if err != nil {
fmt.Println("NewRequest error:", err)
panic(err)
}
req.Close = true
resp, err := httpClient.Do(req)
if err != nil {
fmt.Println("Do error:", err)
panic(err)
}
resp.Body.Close()
time.Sleep(2 * time.Microsecond)
}
```
谁能解释一下,为什么程序跑了大半后会在“resp, err := httpClient.Do(req)”一句报“Post https://localhost:6600/: unexpected EOF”的错误?在此谢谢了!
有疑问加站长微信联系(非本文作者)