HTTP load generator, ApacheBench (ab) replacement
Go
Actually set the hey user agent in the request. (#78)
mdakinc2c7035faead
diff --git a/hey.go b/hey.goindex a065b6b..c320f9c 100644--- a/hey.go+++ b/hey.go@@ -35,6 +35,7 @@ import (const (headerRegexp = `^([\w-]+):\s*(.+)`authRegexp = `^(.+):([^\s].+)`+ heyUA = "hey/0.0.1")var (@@ -197,7 +198,6 @@ func main() {usageAndExit(err.Error())}req.ContentLength = int64(len(bodyAll))- req.Header = headerif username != "" || password != "" {req.SetBasicAuth(username, password)}@@ -207,6 +207,15 @@ func main() {req.Host = *hostHeader}+ ua := req.UserAgent()+ if ua == "" {+ ua = heyUA+ } else {+ ua += " " + heyUA+ }+ header.Set("User-Agent", ua)+ req.Header = header+w := &requester.Work{Request: req,RequestBody: bodyAll,diff --git a/requester/requester.go b/requester/requester.goindex 0a7265b..bd6e58b 100644--- a/requester/requester.go+++ b/requester/requester.go@@ -30,8 +30,6 @@ import ("golang.org/x/net/http2")-const heyUA = "hey/0.0.1"-// Max size of the buffer of result channel.const maxResult = 1000000const maxIdleConn = 500@@ -106,14 +104,6 @@ func (b *Work) writer() io.Writer {// Run makes all the requests, prints the summary. It blocks until// all work is done.func (b *Work) Run() {- // append hey's user agent- ua := b.Request.UserAgent()- if ua == "" {- ua = heyUA- } else {- ua += " " + heyUA- }-b.results = make(chan *result, min(b.C*1000, maxResult))b.stopCh = make(chan struct{}, b.C)b.start = time.Now()