Skip to content

Commit

Permalink
Add a hasty HTTP debug dump
Browse files Browse the repository at this point in the history
  • Loading branch information
tsipinakis committed Mar 4, 2024
1 parent 2b50b03 commit 17aad06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion http/client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"net/http"
"net/http/httputil"
"net/url"

"github.com/gorilla/schema"
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -280,4 +287,4 @@ func (c *client) createHTTPClient(logger log.Logger) *http.Client {
Timeout: c.config.Timeout,
}
return httpClient
}
}
6 changes: 3 additions & 3 deletions http/server_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 17aad06

Please sign in to comment.