Skip to content

Commit

Permalink
add version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengxi Zhang committed Aug 20, 2024
1 parent d8a7c57 commit 547241f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ release:
GOOS=windows GOARCH=amd64 go build -o ./bin/$(binary)_windows_amd64
GOOS=linux GOARCH=amd64 go build -o ./bin/$(binary)_linux_amd64
GOOS=darwin GOARCH=amd64 go build -o ./bin/$(binary)_darwin_amd64
GOOS=darwin GOARCH=arm64 go build -o ./bin/$(binary)_darwin_arm64
21 changes: 12 additions & 9 deletions hey.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
const (
headerRegexp = `^([\w-]+):\s*(.+)`
authRegexp = `^(.+):([^\s].+)`
heyUA = "hey/0.0.1"
heyVersion = "mengxi-hey/1.0.0"
)

var (
Expand Down Expand Up @@ -70,7 +70,10 @@ var (
certKey = flag.String("cert-key", "", "")
)

var usage = `Usage: hey [options...] <url>
var usage = `
Version: %s
Usage: hey [options...] <url>
Options:
-n Number of requests to run. Default is 200.
Expand All @@ -92,7 +95,7 @@ Options:
-d HTTP request body.
-D HTTP request body from file. For example, /home/user/file.txt or ./file.txt.
-T Content-type, defaults to "text/html".
-U User-Agent, defaults to version "hey/0.0.1".
-U User-Agent, defaults to version "%s".
-a Basic authentication, username:password.
-x HTTP Proxy address as host:port.
-h2 Enable HTTP/2.
Expand All @@ -106,13 +109,13 @@ Options:
-cpus Number of used cpu cores.
(default for current machine is %d cores)
-cert file path to the X509 certificate
-cert-key file path to the X509 certidicate key
-cert file path to the client X509 certificate
-cert-key file path to the client X509 certidicate key
`

func main() {
flag.Usage = func() {
fmt.Fprint(os.Stderr, fmt.Sprintf(usage, runtime.NumCPU()))
fmt.Fprint(os.Stderr, fmt.Sprintf(usage, heyVersion, heyVersion, runtime.NumCPU()))
}

var hs headerSlice
Expand Down Expand Up @@ -214,15 +217,15 @@ func main() {

ua := header.Get("User-Agent")
if ua == "" {
ua = heyUA
ua = heyVersion
} else {
ua += " " + heyUA
ua += " " + heyVersion
}
header.Set("User-Agent", ua)

// set userAgent header if set
if *userAgent != "" {
ua = *userAgent + " " + heyUA
ua = *userAgent + " " + heyVersion
header.Set("User-Agent", ua)
}

Expand Down

0 comments on commit 547241f

Please sign in to comment.