From 41e9aa21e77fecb12f41a04f9bfeed44d7d90576 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Tue, 2 Feb 2021 19:24:55 +0530 Subject: [PATCH] Misc --- v2/pkg/protocols/http/request.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/v2/pkg/protocols/http/request.go b/v2/pkg/protocols/http/request.go index 1f154460..095c2fa2 100644 --- a/v2/pkg/protocols/http/request.go +++ b/v2/pkg/protocols/http/request.go @@ -1,7 +1,6 @@ package http import ( - "bytes" "io" "io/ioutil" "net/http" @@ -219,7 +218,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam dumpedRequest []byte fromcache bool ) - if r.options.Options.Debug || r.options.ProjectFile != nil || r.options.Options.DebugRequests { + if r.options.Options.Debug || r.options.ProjectFile != nil || r.options.Options.DebugRequests || r.options.Options.JSONRequests { dumpedRequest, err = dump(request, reqURL) if err != nil { return err @@ -283,7 +282,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam duration := time.Since(timeStart) // Dump response - Step 1 - Decompression not yet handled var dumpedResponse []byte - if r.options.Options.Debug || r.options.Options.DebugResponse { + if r.options.Options.Debug || r.options.Options.DebugResponse || r.options.Options.JSONRequests { var dumpErr error dumpedResponse, dumpErr = httputil.DumpResponse(resp, true) if dumpErr != nil { @@ -302,7 +301,6 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam // net/http doesn't automatically decompress the response body if an // encoding has been specified by the user in the request so in case we have to // manually do it. - dataOrig := data data, err = handleDecompression(request, data) if err != nil { return errors.Wrap(err, "could not decompress http body") @@ -310,7 +308,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam // Dump response - step 2 - replace gzip body with deflated one or with itself (NOP operation) if r.options.Options.Debug || r.options.Options.DebugResponse { - dumpedResponse = bytes.ReplaceAll(dumpedResponse, dataOrig, data) + dumpedResponse = data gologger.Info().Msgf("[%s] Dumped HTTP response for %s\n\n", r.options.TemplateID, formedURL) gologger.Print().Msgf("%s", string(dumpedResponse)) }