将签名认证超时时间改为 5 秒
diff --git a/webservice.go b/webservice.go
index 086d4d5..6a9955e 100644
--- a/webservice.go
+++ b/webservice.go
@@ -116,7 +116,8 @@
}
// DoGet send GET request
-func (w *WebSession) DoGet(uri string, params map[string]string) (*goreq.Response, error) {
+func (w *WebSession) DoGet(uri string, params map[string]string,
+ timeout int) (*goreq.Response, error) {
fullURL := w.BaseURL + uri
@@ -128,7 +129,9 @@
}
}
fullURL = fullURL + "?" + vl.Encode()
- return goreq.Request{Uri: fullURL, Method: "GET"}.Do()
+ return goreq.Request{Uri: fullURL,
+ Method: "GET",
+ Timeout: time.Duration(timeout) * time.Second}.Do()
}
// GetTimestamp get time stamp format 20160103133455
@@ -268,7 +271,7 @@
params := make(map[string]string)
params["term_id"] = w.TermID
- r, err := w.DoGet(uri, params)
+ r, err := w.DoGet(uri, params, 5)
if err != nil {
return "", err
@@ -307,7 +310,7 @@
params["sign"] = w.Sign(token + params["timestamp"])
params["sign_method"] = "HMAC"
- r, err := w.DoGet(uri, params)
+ r, err := w.DoGet(uri, params, 5)
if r != nil {
defer r.Body.Close()
}