diff --git a/ftwhttp/connection.go b/ftwhttp/connection.go index 2ed9c0e..f02f333 100644 --- a/ftwhttp/connection.go +++ b/ftwhttp/connection.go @@ -3,6 +3,7 @@ package ftwhttp import ( "bufio" + "bytes" "errors" "io" "net" @@ -104,13 +105,20 @@ func (c *Connection) Response() (*Response, error) { return nil, err } - reader := *bufio.NewReader(r) + buf := &bytes.Buffer{} + + reader := *bufio.NewReader(io.TeeReader(r, buf)) httpResponse, err := http.ReadResponse(&reader, nil) if err != nil { return nil, err } + + data := buf.Bytes() + log.Trace().Msgf("ftw/http: received data - %q", data) + response := Response{ + RAW: data, Parsed: *httpResponse, } return &response, err diff --git a/ftwhttp/types.go b/ftwhttp/types.go index 7b5e39f..de29c47 100644 --- a/ftwhttp/types.go +++ b/ftwhttp/types.go @@ -71,5 +71,6 @@ type Request struct { // Response represents the http response received from the server/waf type Response struct { + RAW []byte Parsed http.Response }