diff --git a/cmd/fuzz/main.go b/cmd/fuzz/main.go index 572e0fa..c528d74 100644 --- a/cmd/fuzz/main.go +++ b/cmd/fuzz/main.go @@ -319,7 +319,8 @@ func startRunners(ctx context.Context, opts *Options, in <-chan string) (<-chan out := make(chan response.Response) var wg sync.WaitGroup - transport, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, opts.Request.DisableHTTP2) + transport, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, + opts.Request.DisableHTTP2, opts.Threads) if err != nil { return nil, err } diff --git a/cmd/test/main.go b/cmd/test/main.go index 0964fe8..2320c2f 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -115,7 +115,8 @@ func run(ctx context.Context, g *errgroup.Group, opts *Options, args []string) e output := make(chan response.Response, 1) - tr, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, opts.Request.DisableHTTP2) + tr, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, + opts.Request.DisableHTTP2, 1) if err != nil { return err } diff --git a/response/runner.go b/response/runner.go index 1f63fa1..72e549a 100644 --- a/response/runner.go +++ b/response/runner.go @@ -34,7 +34,8 @@ type Runner struct { const DefaultBodyBufferSize = 5 * 1024 * 1024 // NewTransport creates a new shared transport for clients to use. -func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 bool) (*http.Transport, error) { +func NewTransport(insecure bool, TLSClientCertKeyFilename string, + disableHTTP2 bool, concurrentRequests int) (*http.Transport, error) { // for timeouts, see // https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ tr := &http.Transport{ @@ -48,6 +49,8 @@ func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 b ExpectContinueTimeout: 1 * time.Second, IdleConnTimeout: 15 * time.Second, TLSClientConfig: &tls.Config{}, + MaxIdleConns: concurrentRequests, + MaxIdleConnsPerHost: concurrentRequests, } if insecure {