From 2e717bc6ec317dabf5fc229ff975d97fc43c447f Mon Sep 17 00:00:00 2001 From: jason-gao <3048789891@qq.com> Date: Mon, 7 Jan 2019 21:49:45 -0800 Subject: [PATCH] fix:callback url request fail error deal --- notifer.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/notifer.go b/notifer.go index 907e9fc..ed7c22c 100644 --- a/notifer.go +++ b/notifer.go @@ -62,7 +62,15 @@ func (n *NetNotifier) dispatch(params *postParams) { req.Header.Set("Content-Type", "application/json;charset=UTF-8") req.Header.Set("User-Agent", "FileBoy Net Notifier v1.5") resp, err := client.Do(req) - defer resp.Body.Close() + if err != nil { + log.Println("notifier call failed. err:", err) + return + } + defer func() { + if resp != nil && resp.Body != nil { + _ = resp.Body.Close() + } + }() if resp.StatusCode >= 300 { // todo retry??? }