From 17aad067dc8e73aed2cf7ff88c5a452e593934ec Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Mon, 4 Mar 2024 21:14:43 +0100 Subject: [PATCH] Add a hasty HTTP debug dump --- http/client_impl.go | 9 ++++++++- http/server_impl.go | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/http/client_impl.go b/http/client_impl.go index e66146cd..09c9cf01 100644 --- a/http/client_impl.go +++ b/http/client_impl.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "net/http" + "net/http/httputil" "net/url" "github.com/gorilla/schema" @@ -132,6 +133,9 @@ func (c *client) requestURLWithLogger( logger.Debug(message.NewMessage(message.MHTTPClientRequest, "HTTP %s request to %s", method, u)) + reqDump, _ := httputil.DumpRequestOut(req, true) + fmt.Printf("REQUEST:\n%s", string(reqDump)) + resp, err := httpClient.Do(req) if err != nil { var typedError message.Message @@ -145,6 +149,9 @@ func (c *client) requestURLWithLogger( } defer func() { _ = resp.Body.Close() }() + reqDump, _ = httputil.DumpResponse(resp, true) + fmt.Printf("RESPONSE:\n%s", string(reqDump)) + logger.Debug( message.NewMessage( message.MHTTPClientResponse, @@ -280,4 +287,4 @@ func (c *client) createHTTPClient(logger log.Logger) *http.Client { Timeout: c.config.Timeout, } return httpClient -} \ No newline at end of file +} diff --git a/http/server_impl.go b/http/server_impl.go index 6cbc7ab3..8b541950 100644 --- a/http/server_impl.go +++ b/http/server_impl.go @@ -10,9 +10,9 @@ import ( goHttp "net/http" "sync" - "go.containerssh.io/libcontainerssh/config" - "go.containerssh.io/libcontainerssh/message" - "go.containerssh.io/libcontainerssh/service" + "go.containerssh.io/libcontainerssh/config" + "go.containerssh.io/libcontainerssh/message" + "go.containerssh.io/libcontainerssh/service" ) type server struct {