-
Notifications
You must be signed in to change notification settings - Fork 105
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
404的错误 #2
Comments
测试一下resp.Status != 200时候,是不是导致错误 |
resp.Status != 200并不认为是错误,body还是有的,通过 |
在什么情况下会没有body,昨天我用了,估计是没有读到body,也没有出现错误,导致后面对body的处理失败,程序退出了 发件人: dong |
res, err := client.Get(url, nil)
if err == nil {
// res.Body might be nil
} else {
fmt.Println(res.ToString())
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果访问一个不存在的链接,会不会导致没有body,导致错误呢
// Read response body into string.
func (this *Response) ToString() (string, error) {
defer this.Body.Close()
bytes, err := ioutil.ReadAll(this.Body)
if err != nil {
return "", err
}
}
The text was updated successfully, but these errors were encountered: