diff --git a/.gitignore b/.gitignore index 553c47b0..345a84f3 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,3 @@ coverage.txt # Go workspace file go.work - -# Log files -*.log diff --git a/Makefile b/Makefile index 12c05cde..ee18a8f6 100644 --- a/Makefile +++ b/Makefile @@ -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'` diff --git a/client/client.go b/client/client.go index ee355547..3d78901b 100644 --- a/client/client.go +++ b/client/client.go @@ -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 @@ -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 diff --git a/internal/clientv2/interceptor_debug.go b/internal/clientv2/interceptor_debug.go index 630fddfe..6a5ecf2a 100644 --- a/internal/clientv2/interceptor_debug.go +++ b/internal/clientv2/interceptor_debug.go @@ -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" ) @@ -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 } @@ -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 }