MCPcopy Index your code
hub / github.com/ContentSquare/chproxy / readAndRestoreRequestBody

Function readAndRestoreRequestBody

utils.go:309–320  ·  view source on GitHub ↗

Function to read the request body and return it as a byte slice. It also restores the req.Body to be used again.

(req *http.Request)

Source from the content-addressed store, hash-verified

307// Function to read the request body and return it as a byte slice.
308// It also restores the req.Body to be used again.
309func readAndRestoreRequestBody(req *http.Request) ([]byte, error) {
310 // Read the entire request body.
311 body, err := io.ReadAll(req.Body)
312 if err != nil {
313 return nil, err
314 }
315 // Restore the req.Body with a new reader for the original content.
316 req.Body = io.NopCloser(bytes.NewReader(body))
317
318 // Return the read body.
319 return body, nil
320}

Callers 1

executeWithRetryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected