Skip to content

Commit

Permalink
Revert "Adjust client debug request/response print"
Browse files Browse the repository at this point in the history
  • Loading branch information
miclle authored Jan 15, 2025
1 parent 93253a8 commit 294b5ed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 45 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ coverage.txt

# Go workspace file
go.work

# Log files
*.log
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
go test -tags='unit integration' -failfast -count=1 -v -timeout 350m -coverprofile=coverage.txt `go list ./... | egrep -v 'examples|sms'` | tee -a test.log
go test -tags='unit integration' -failfast -count=1 -v -timeout 350m -coverprofile=coverage.txt `go list ./... | egrep -v 'examples|sms'`

unittest:
go test -tags=unit -failfast -count=1 -v -coverprofile=coverage.txt `go list ./... | egrep -v 'examples|sms'`
Expand Down
22 changes: 2 additions & 20 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,7 @@ func newRequest(ctx context.Context, method, reqUrl string, headers http.Header,
},
}
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))

var (
hasBody = DeepDebugInfo
contentType = req.Header.Get("Content-Type")
)
if contentType != conf.CONTENT_TYPE_JSON && contentType != conf.CONTENT_TYPE_FORM {
hasBody = false
}

bs, bErr := httputil.DumpRequest(req, hasBody)
bs, bErr := httputil.DumpRequest(req, DeepDebugInfo)
if bErr != nil {
err = bErr
return
Expand Down Expand Up @@ -302,16 +293,7 @@ func CallRet(ctx context.Context, ret interface{}, resp *http.Response) (err err
}()

if DebugMode {

var hasBody = DeepDebugInfo
switch {
case
resp.Header.Get("Content-Type") == "application/octet-stream",
resp.ContentLength <= 0 || resp.ContentLength > 1024*1024:
hasBody = false
}

bs, dErr := httputil.DumpResponse(resp, hasBody)
bs, dErr := httputil.DumpResponse(resp, DeepDebugInfo)
if dErr != nil {
err = dErr
return
Expand Down
23 changes: 2 additions & 21 deletions internal/clientv2/interceptor_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http/httputil"

clientV1 "github.com/qiniu/go-sdk/v7/client"
"github.com/qiniu/go-sdk/v7/conf"
"github.com/qiniu/go-sdk/v7/internal/log"
)

Expand Down Expand Up @@ -121,16 +120,7 @@ func (interceptor *debugInterceptor) printRequest(label string, req *http.Reques
}

info := label + " request:\n"

var (
hasBody = IsPrintRequestBody()
contentType = req.Header.Get("Content-Type")
)
if contentType != conf.CONTENT_TYPE_JSON && contentType != conf.CONTENT_TYPE_FORM {
hasBody = false
}

d, dErr := httputil.DumpRequest(req, hasBody)
d, dErr := httputil.DumpRequest(req, IsPrintRequestBody())
if dErr != nil {
return dErr
}
Expand Down Expand Up @@ -209,16 +199,7 @@ func (interceptor *debugInterceptor) printResponse(label string, resp *http.Resp
}

info := label + " response:\n"

var hasBody = IsPrintResponseBody()
switch {
case
resp.Header.Get("Content-Type") == "application/octet-stream",
resp.ContentLength <= 0 || resp.ContentLength > 1024*1024:
hasBody = false
}

d, dErr := httputil.DumpResponse(resp, hasBody)
d, dErr := httputil.DumpResponse(resp, IsPrintResponseBody())
if dErr != nil {
return dErr
}
Expand Down

0 comments on commit 294b5ed

Please sign in to comment.