@@ -244,6 +244,10 @@ func (c *Client) DefaultPaginationParameters(length int) *PaginationParameters {
244244
245245// Do performs the HTTP request on the wire, taking an optional second parameter for containing a response
246246func (c * Client ) Do (req * http.Request , respData interface {}) (* http.Response , error ) {
247+ if c .debugMode {
248+ dumpRequest (req )
249+ }
250+
247251 resp , err := c .httpClient .Do (req )
248252
249253 // error in performing request
@@ -307,7 +311,7 @@ func dumpResponse(resp *http.Response) {
307311 fmt .Printf ("response status: %s\n " , resp .Status )
308312 if resp .ContentLength != 0 {
309313 if respBytes , err := ioutil .ReadAll (resp .Body ); err != nil {
310- log .Printf ("Error reading body: %s" , err )
314+ log .Printf ("error reading body: %s" , err )
311315 return
312316 } else {
313317 resp .Body .Close ()
@@ -316,3 +320,19 @@ func dumpResponse(resp *http.Response) {
316320 }
317321 }
318322}
323+
324+ // dumpRequest is a debugging function which dumps the HTTP request to stdout
325+ func dumpRequest (req * http.Request ) {
326+ if req .Body == nil {
327+ return
328+ }
329+
330+ if reqBytes , err := ioutil .ReadAll (req .Body ); err != nil {
331+ log .Printf ("error reading body: %s" , err )
332+ return
333+ } else {
334+ req .Body .Close ()
335+ req .Body = ioutil .NopCloser (bytes .NewBuffer (reqBytes ))
336+ log .Printf ("request body: %s\n \n " , string (reqBytes ))
337+ }
338+ }
0 commit comments