Don’t use Go’s default HTTP client
直接使用Go语言的http.Post,http.Get等方法时,底层连接使用的是DefaultClient。而DefaultClient没有设置请求超时:
// DefaultClient is the default Client and is used by Get, Head, and Post.
var DefaultClient = &Client{}
因此,如果服务器端如果一直无响应的话,就会把当前发出请求的goroutine挂死。因此如果要使用DefaultClient,一定要
原创
2021-02-05 11:50:17 ·
190 阅读 ·
0 评论