forked from go-packages/paypal
Fixed panic on logging requests without body (GET)
This commit is contained in:
parent
72454421ef
commit
be08e9ec4a
|
@ -135,8 +135,6 @@ func (c *Client) NewRequest(method, url string, payload interface{}) (*http.Requ
|
||||||
func (c *Client) log(r *http.Request, resp *http.Response) {
|
func (c *Client) log(r *http.Request, resp *http.Response) {
|
||||||
if c.Log != nil {
|
if c.Log != nil {
|
||||||
reqDump := fmt.Sprintf("%s %s. Data: %s", r.Method, r.URL.String(), r.Form.Encode())
|
reqDump := fmt.Sprintf("%s %s. Data: %s", r.Method, r.URL.String(), r.Form.Encode())
|
||||||
dump, _ := ioutil.ReadAll(r.Body)
|
|
||||||
fmt.Println(string(dump))
|
|
||||||
respDump, _ := httputil.DumpResponse(resp, true)
|
respDump, _ := httputil.DumpResponse(resp, true)
|
||||||
|
|
||||||
c.Log.Write([]byte("Request: " + reqDump + "\nResponse: " + string(respDump) + "\n\n"))
|
c.Log.Write([]byte("Request: " + reqDump + "\nResponse: " + string(respDump) + "\n\n"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user