Skip to content

Commit 8335b9b

Browse files
committed
Merge branch 'pr-304': add response handle from timeout
增加对http请求超时后resp的处理 ouqiang#304
2 parents 1889f9f + a249cbc commit 8335b9b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/modules/httpclient/http_client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func request(req *http.Request, timeout int) ResponseWrapper {
5555
}
5656
setRequestHeader(req)
5757
resp, err := client.Do(req)
58+
if resp == nil{
59+
wrapper.Body = fmt.Sprintf("执行HTTP请求超时")
60+
return wrapper
61+
}
5862
if err != nil {
5963
wrapper.Body = fmt.Sprintf("执行HTTP请求错误-%s", err.Error())
6064
return wrapper

0 commit comments

Comments
 (0)