Documentation
¶
Index ¶
- Constants
- type CaptureResponseWriter
- func (sw *CaptureResponseWriter) Body() []byte
- func (sw *CaptureResponseWriter) Header() http.Header
- func (sw *CaptureResponseWriter) StatusCode() int
- func (sw *CaptureResponseWriter) Truncated() bool
- func (sw *CaptureResponseWriter) Write(b []byte) (int, error)
- func (sw *CaptureResponseWriter) WriteHeader(code int)
Constants ¶
const DefaultMaxBytes = 256 * 1024 * 1024
DefaultMaxBytes is the per-writer cap applied by NewCaptureResponseWriterWithLimit when callers want defense-in-depth against pathological upstream responses blowing the heap during ALB fanout. 256 MiB is generous for legitimate time-series payloads and stops one bad backend from OOMing the proxy.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaptureResponseWriter ¶
type CaptureResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
CaptureResponseWriter captures the response body to a byte slice
func NewCaptureResponseWriter ¶
func NewCaptureResponseWriter() *CaptureResponseWriter
NewCaptureResponseWriter returns a new CaptureResponseWriter
func NewCaptureResponseWriterWithLimit ¶ added in v2.0.2
func NewCaptureResponseWriterWithLimit(maxBytes int) *CaptureResponseWriter
NewCaptureResponseWriterWithLimit returns a CaptureResponseWriter that drops bytes past maxBytes and flips Truncated() to true. A non-positive maxBytes means unlimited.
func (*CaptureResponseWriter) Body ¶
func (sw *CaptureResponseWriter) Body() []byte
Body returns the captured response body
func (*CaptureResponseWriter) Header ¶
func (sw *CaptureResponseWriter) Header() http.Header
Header returns the response header map
func (*CaptureResponseWriter) StatusCode ¶
func (sw *CaptureResponseWriter) StatusCode() int
StatusCode returns the captured status code
func (*CaptureResponseWriter) Truncated ¶ added in v2.0.2
func (sw *CaptureResponseWriter) Truncated() bool
Truncated reports whether Write dropped bytes due to hitting maxBytes.
func (*CaptureResponseWriter) Write ¶
func (sw *CaptureResponseWriter) Write(b []byte) (int, error)
Write appends data to the response body. Returns len(b) even after the cap is reached so the upstream producer doesn't error or block; Truncated() surfaces the drop to the merge layer.
func (*CaptureResponseWriter) WriteHeader ¶
func (sw *CaptureResponseWriter) WriteHeader(code int)
WriteHeader sets the status code and, when Content-Length is set and the body has not yet been grown, presizes body to skip bytes.Buffer's doubling-copies on large upstream responses. Bounded by maxBytes so a misreported huge CL cannot blow the cap.