diff --git a/go.mod b/go.mod
index b2f3b7b..ee859f2 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,4 @@ module github.com/solarhell/wechat-open-platform
go 1.12
-require github.com/imroc/req v0.3.0
+require github.com/imroc/req v0.3.2
diff --git a/go.sum b/go.sum
index 0f3680c..2c66909 100644
--- a/go.sum
+++ b/go.sum
@@ -1,4 +1,2 @@
-github.com/imroc/req v0.2.4 h1:8XbvaQpERLAJV6as/cB186DtH5f0m5zAOtHEaTQ4ac0=
-github.com/imroc/req v0.2.4/go.mod h1:J9FsaNHDTIVyW/b5r6/Df5qKEEEq2WzZKIgKSajd1AE=
-github.com/imroc/req v0.3.0 h1:3EioagmlSG+z+KySToa+Ylo3pTFZs+jh3Brl7ngU12U=
-github.com/imroc/req v0.3.0/go.mod h1:F+NZ+2EFSo6EFXdeIbpfE9hcC233id70kf0byW97Caw=
+github.com/imroc/req v0.3.2 h1:M/JkeU6RPmX+WYvT2vaaOL0K+q8ufL5LxwvJc4xeB4o=
+github.com/imroc/req v0.3.2/go.mod h1:F+NZ+2EFSo6EFXdeIbpfE9hcC233id70kf0byW97Caw=
diff --git a/vendor/github.com/imroc/req/README.md b/vendor/github.com/imroc/req/README.md
index 7d54deb..8319dab 100644
--- a/vendor/github.com/imroc/req/README.md
+++ b/vendor/github.com/imroc/req/README.md
@@ -81,7 +81,7 @@ param := req.Param{
"cmd": "add",
}
// only url is required, others are optional.
-r, err = req.Post("http://foo.bar/api", header, param)
+r, err := req.Post("http://foo.bar/api", header, param)
if err != nil {
log.Fatal(err)
}
@@ -161,7 +161,7 @@ req.Post(url, req.BodyXML(&bar))
```
## Debug
-Set global variable `req.Debug` to true, it will print detail infomation for every request.
+Set global variable `req.Debug` to true, it will print detail information for every request.
``` go
req.Debug = true
req.Post("http://localhost/test" "hi")
@@ -169,7 +169,7 @@ req.Post("http://localhost/test" "hi")

## Output Format
-You can use different kind of output format to log the request and response infomation in your log file in defferent scenarios. For example, use `%+v` output format in the development phase, it allows you to observe the details. Use `%v` or `%-v` output format in production phase, just log the information necessarily.
+You can use different kind of output format to log the request and response information in your log file in defferent scenarios. For example, use `%+v` output format in the development phase, it allows you to observe the details. Use `%v` or `%-v` output format in production phase, just log the information necessarily.
### `%+v` or `%+s`
Output in detail
diff --git a/vendor/github.com/imroc/req/dump.go b/vendor/github.com/imroc/req/dump.go
index ce6d3a5..52e527e 100644
--- a/vendor/github.com/imroc/req/dump.go
+++ b/vendor/github.com/imroc/req/dump.go
@@ -207,10 +207,11 @@ func (r *Resp) Dump() string {
l := dump.Len()
if l > 0 {
dump.WriteString("=================================")
- l = dump.Len()
}
- r.dumpResponse(dump)
+ if r.resp != nil {
+ r.dumpResponse(dump)
+ }
return dump.String()
}
diff --git a/vendor/github.com/imroc/req/header.go b/vendor/github.com/imroc/req/header.go
index ac1be32..dbc5992 100644
--- a/vendor/github.com/imroc/req/header.go
+++ b/vendor/github.com/imroc/req/header.go
@@ -39,3 +39,4 @@ func HeaderFromStruct(v interface{}) Header {
return header
}
+type ReservedHeader map[string]string
diff --git a/vendor/github.com/imroc/req/req.go b/vendor/github.com/imroc/req/req.go
index 01937f0..99c04b3 100644
--- a/vendor/github.com/imroc/req/req.go
+++ b/vendor/github.com/imroc/req/req.go
@@ -171,6 +171,13 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
}
resp = &Resp{req: req, r: r}
+ // output detail if Debug is enabled
+ if Debug {
+ defer func(resp *Resp) {
+ fmt.Println(resp.Dump())
+ }(resp)
+ }
+
var queryParam param
var formParam param
var uploads []FileUpload
@@ -191,6 +198,10 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
req.Header.Add(key, value)
}
}
+ case ReservedHeader:
+ for key, value := range vv {
+ req.Header[key] = []string{value}
+ }
case *bodyJson:
fn, err := setBodyJson(req, resp, r.jsonEncOpts, vv.v)
if err != nil {
@@ -340,10 +351,6 @@ func (r *Req) Do(method, rawurl string, vs ...interface{}) (resp *Resp, err erro
response.Body = body
}
- // output detail if Debug is enabled
- if Debug {
- fmt.Println(resp.Dump())
- }
return
}
diff --git a/vendor/github.com/imroc/req/resp.go b/vendor/github.com/imroc/req/resp.go
index b464c2b..e5c36fc 100644
--- a/vendor/github.com/imroc/req/resp.go
+++ b/vendor/github.com/imroc/req/resp.go
@@ -43,7 +43,7 @@ func (r *Resp) Bytes() []byte {
}
// ToBytes returns response body as []byte,
-// return error if error happend when reading
+// return error if error happened when reading
// the response body
func (r *Resp) ToBytes() ([]byte, error) {
if r.err != nil {
@@ -69,7 +69,7 @@ func (r *Resp) String() string {
}
// ToString returns response body as string,
-// return error if error happend when reading
+// return error if error happened when reading
// the response body
func (r *Resp) ToString() (string, error) {
data, err := r.ToBytes()
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 7379466..ac7b47b 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,2 +1,2 @@
-# github.com/imroc/req v0.3.0
+# github.com/imroc/req v0.3.2
github.com/imroc/req