fix http debugger

This commit is contained in:
2026-05-29 11:27:40 +02:00
parent f7302ea506
commit 57bbe680a7

View File

@@ -246,8 +246,11 @@ type DebugTransport struct {
}
func (t *DebugTransport) RoundTrip(req *http.Request) (*http.Response, error) {
buf := new(bytes.Buffer)
content := ""
contentline := ""
if req.ContentLength > 0 {
buf := new(bytes.Buffer)
body, _ := req.GetBody()
_, err := buf.ReadFrom(body)
@@ -261,7 +264,11 @@ func (t *DebugTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, fmt.Errorf("json parse error: %s", err)
}
slog.Info("req", "host", req.URL.Host, "uri", req.URL.Path, "body", pretty.String(), "bodyline", buf.String())
content = pretty.String()
contentline = buf.String()
}
slog.Info("req", "host", req.URL.Host, "uri", req.URL.Path, "body", content, "bodyline", contentline)
return t.Transport.RoundTrip(req)
}