Actually set the hey user agent in the request. (#78)

This commit is contained in:
mdakin
2017-12-26 20:03:03 +01:00
committed by GitHub
parent 0e59549516
commit c2c7035fae
2 changed files with 10 additions and 11 deletions
+10 -1
View File
@@ -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 = header
if 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,
-10
View File
@@ -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 = 1000000
const 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()