diff options
Diffstat (limited to 'internal/proxy/capture.go')
| -rw-r--r-- | internal/proxy/capture.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/internal/proxy/capture.go b/internal/proxy/capture.go index ec4dc8d..3902e5c 100644 --- a/internal/proxy/capture.go +++ b/internal/proxy/capture.go @@ -36,12 +36,19 @@ func (c *cappedTee) Read(p []byte) (int, error) { // captureRequest returns the raw bytes of r for storage. When tee is // non-nil (an HTTP/1.1 client connection), the bytes are exactly what -// was read off the wire. Otherwise (HTTP/2, which has no single "raw -// bytes" representation - it's multiplexed, HPACK-compressed framing) -// it's a reconstruction from the parsed request, exact=false. -func captureRequest(r *http.Request, tee *teeConn, bodyCap *cappedTee) (raw []byte, exact bool) { +// was read off the wire, unless truncated hits maxCaptureBytes and has +// to drop bytes off the end - still real wire bytes, just incomplete, +// which is a different (and less severe) kind of "not exact" than the +// HTTP/2 case below and worth telling apart in the UI (see +// store.Entry's *Truncated fields). Otherwise (HTTP/2, which has no +// single "raw bytes" representation - it's multiplexed, HPACK- +// compressed framing) it's a reconstruction from the parsed request, +// exact=false, truncated=false (truncated only applies to a would-be- +// exact capture). +func captureRequest(r *http.Request, tee *teeConn, bodyCap *cappedTee) (raw []byte, exact, truncated bool) { if tee != nil { - return tee.Take(), true + data, truncated := tee.Take() + return data, !truncated, truncated } dump := r.Clone(r.Context()) @@ -54,9 +61,9 @@ func captureRequest(r *http.Request, tee *teeConn, bodyCap *cappedTee) (raw []by } var buf bytes.Buffer if err := dump.Write(&buf); err != nil { - return nil, false + return nil, false, false } - return buf.Bytes(), false + return buf.Bytes(), false, false } // captureResponse reconstructs raw response bytes from the parsed |