Use the standard library request cloner

This commit is contained in:
JBD
2026-01-10 12:24:33 -08:00
parent 2a27143475
commit dc0126a7ec
+1 -9
View File
@@ -264,16 +264,8 @@ func (b *Work) runWorkers() {
}
// cloneRequest returns a clone of the provided *http.Request.
// The clone is a shallow copy of the struct and its Header map.
func cloneRequest(r *http.Request, body []byte) *http.Request {
// shallow copy of the struct
r2 := new(http.Request)
*r2 = *r
// deep copy of the Header
r2.Header = make(http.Header, len(r.Header))
for k, s := range r.Header {
r2.Header[k] = append([]string(nil), s...)
}
r2 := r.Clone(r.Context())
if len(body) > 0 {
r2.Body = io.NopCloser(bytes.NewReader(body))
}