MCPcopy Create free account
hub / github.com/coder/coder / resetRequestBody

Function resetRequestBody

coderd/x/chatd/chatdebug/transport.go:194–207  ·  view source on GitHub ↗

resetRequestBody replaces req.Body with a fresh reader from req.GetBody. It closes the previous request body before installing the replacement. Callers must ensure req.GetBody is non-nil.

(req *http.Request)

Source from the content-addressed store, hash-verified

192// It closes the previous request body before installing the replacement.
193// Callers must ensure req.GetBody is non-nil.
194func resetRequestBody(req *http.Request) error {
195 body, err := req.GetBody()
196 if err != nil {
197 return err
198 }
199 if req.Body != nil {
200 if err := req.Body.Close(); err != nil {
201 _ = body.Close()
202 return err
203 }
204 }
205 req.Body = body
206 return nil
207}
208
209type recordingBody struct {
210 inner io.ReadCloser

Callers 1

captureRequestBodyFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected