Skip to content

Commit ab02f20

Browse files
authored
refactor: inherit value from client enables clean request overrides #516 (#706)
1 parent 0424ad1 commit ab02f20

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,17 +433,18 @@ func (c *Client) SetDigestAuth(username, password string) *Client {
433433
// R method creates a new request instance, its used for Get, Post, Put, Delete, Patch, Head, Options, etc.
434434
func (c *Client) R() *Request {
435435
r := &Request{
436-
QueryParam: url.Values{},
437-
FormData: url.Values{},
438-
Header: http.Header{},
439-
Cookies: make([]*http.Cookie, 0),
436+
QueryParam: url.Values{},
437+
FormData: url.Values{},
438+
Header: http.Header{},
439+
Cookies: make([]*http.Cookie, 0),
440+
PathParams: map[string]string{},
441+
RawPathParams: map[string]string{},
442+
Debug: c.Debug,
440443

441444
client: c,
442445
multipartFiles: []*File{},
443446
multipartFields: []*MultipartField{},
444-
PathParams: map[string]string{},
445-
RawPathParams: map[string]string{},
446-
jsonEscapeHTML: true,
447+
jsonEscapeHTML: c.jsonEscapeHTML,
447448
log: c.log,
448449
}
449450
return r

middleware.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func addCredentials(c *Client, r *Request) error {
277277
}
278278

279279
func requestLogger(c *Client, r *Request) error {
280-
if c.Debug || r.Debug {
280+
if r.Debug {
281281
rr := r.RawRequest
282282
rl := &RequestLog{Header: copyHeaders(rr.Header), Body: r.fmtBodyString(c.debugBodySizeLimit)}
283283
if c.requestLog != nil {
@@ -307,7 +307,7 @@ func requestLogger(c *Client, r *Request) error {
307307
//_______________________________________________________________________
308308

309309
func responseLogger(c *Client, res *Response) error {
310-
if c.Debug || res.Request.Debug {
310+
if res.Request.Debug {
311311
rl := &ResponseLog{Header: copyHeaders(res.Header()), Body: res.fmtBodyString(c.debugBodySizeLimit)}
312312
if c.responseLog != nil {
313313
if err := c.responseLog(rl); err != nil {

0 commit comments

Comments
 (0)