Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

disable HTTP/2 if -h2 is turned off

xuqingfeng5b477b35d547
diff --git a/boom.go b/boom.go
index 5b840fd..7971c4c 100644
--- a/boom.go
+++ b/boom.go
@@ -89,7 +89,7 @@ Options:
-a Basic authentication, username:password.
-x HTTP Proxy address as host:port.
- -h2 Make HTTP2 request.
+ -h2 Make HTTP/2 requests.
-disable-compression Disable compression.
-disable-keepalive Disable keep-alive, prevents re-use of TCP
diff --git a/boomer/boomer.go b/boomer/boomer.go
index 57448c5..c165ae1 100644
--- a/boomer/boomer.go
+++ b/boomer/boomer.go
@@ -17,7 +17,6 @@ package boomer
import (
"crypto/tls"
- "golang.org/x/net/http2"
"io"
"io/ioutil"
"net/http"
@@ -27,6 +26,8 @@ import (
"strings"
"sync"
"time"
+
+ "golang.org/x/net/http2"
)
type result struct {
@@ -48,7 +49,7 @@ type Boomer struct {
// C is the concurrency level, the number of concurrent workers to run.
C int
- // H2 is an option to make HTTP2 requests
+ // H2 is an option to make HTTP/2 requests
H2 bool
// Timeout in seconds.
@@ -133,6 +134,8 @@ func (b *Boomer) runWorker(n int) {
}
if b.H2 {
http2.ConfigureTransport(tr)
+ } else {
+ tr.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)
}
client := &http.Client{Transport: tr}
for i := 0; i < n; i++ {