HTTP load generator, ApacheBench (ab) replacement
Go
Use the standard library request cloner
JBDdc0126a7ec87
diff --git a/requester/requester.go b/requester/requester.goindex aac946b..9bb104d 100644--- a/requester/requester.go+++ b/requester/requester.go@@ -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))}