HTTP load generator, ApacheBench (ab) replacement
Go
fix issue #82: Header values cannot contain semicolons
Nick Tand772b7c0696f
diff --git a/README.md b/README.mdindex 4b25620..7ef3011 100644--- a/README.md+++ b/README.md@@ -28,7 +28,8 @@ Options:metrics in comma-seperated values format.-m HTTP method, one of GET, POST, PUT, DELETE, HEAD, OPTIONS.- -h Custom HTTP headers, name1:value1;name2:value2.+ -h Semicolon-separated list of Custom HTTP headers, name1:value1;name2:value2.+ -H Custom HTTP header. You can specify as many as needed by repeating the flag.-t Timeout in ms.-A HTTP Accept header.-d HTTP request body.diff --git a/boom.go b/boom.goindex a6076bf..d3207db 100644--- a/boom.go+++ b/boom.go@@ -33,7 +33,19 @@ const (authRegexp = "^([\\w-\\.]+):(.+)")+type headerSlice []string++func (h *headerSlice) String() string {+ return fmt.Sprintf("%s", *h)+}++func (h *headerSlice) Set(value string) error {+ *h = append(*h, value)+ return nil+}+var (+ headerslice headerSlicem = flag.String("m", "GET", "")headers = flag.String("h", "", "")body = flag.String("d", "", "")@@ -68,7 +80,8 @@ Options:metrics in comma-seperated values format.-m HTTP method, one of GET, POST, PUT, DELETE, HEAD, OPTIONS.- -h Custom HTTP headers, name1:value1;name2:value2.+ -h Semicolon-separated list of Custom HTTP headers, name1:value1;name2:value2.+ -H Custom HTTP header. You can specify as many as needed by repeating the flag.-t Timeout in ms.-A HTTP Accept header.-d HTTP request body.@@ -90,6 +103,8 @@ func main() {fmt.Fprint(os.Stderr, fmt.Sprintf(usage, runtime.NumCPU()))}+ flag.Var(&headerslice, "H", "")+flag.Parse()if flag.NArg() < 1 {usageAndExit("")@@ -128,6 +143,14 @@ func main() {header.Set(match[1], match[2])}}+ // set any other additional repeatable headers+ for i := 0; i < len(headerslice); i++ {+ match, err := parseInputWithRegexp(headerslice[i], headerRegexp)+ if err != nil {+ usageAndExit(err.Error())+ }+ header.Set(match[1], match[2])+ }if *accept != "" {header.Set("Accept", *accept)