Skip to content

Commit 89d16a7

Browse files
committed
added copy response body function
1 parent b3c1126 commit 89d16a7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

models.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ func (d *DBClient) captureRequest(req *http.Request) (*http.Response, error) {
106106
return resp, err
107107
}
108108

109+
func copyBody(body io.ReadCloser) (resp1, resp2 io.ReadCloser, err error) {
110+
var buf bytes.Buffer
111+
if _, err = buf.ReadFrom(body); err != nil {
112+
return nil, nil, err
113+
}
114+
if err = body.Close(); err != nil {
115+
return nil, nil, err
116+
}
117+
return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewReader(buf.Bytes())), nil
118+
}
109119
// doRequest performs original request and returns response that should be returned to client and error (if there is one)
110120
func (d *DBClient) doRequest(request *http.Request) (*http.Response, error) {
111121
// We can't have this set. And it only contains "/pkg/net/http/" anyway

0 commit comments

Comments
 (0)