diff --git a/README.md b/README.md index d0997fd..93d3f8b 100644 --- a/README.md +++ b/README.md @@ -179,10 +179,10 @@ Function: Example: Client Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomDate \"YMD\"}}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomDate 'YMD' }}" -verbose 0 Body Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomDate \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomDate 'YMD' }}" -verbose 0 ``` **(4) randomString** @@ -221,10 +221,10 @@ Function: Example: Client Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ date \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ date 'YMD' }}" -verbose 0 Body Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ date \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ date 'YMD' }}" -verbose 0 ``` **(7) UUID** diff --git a/README_CN.md b/README_CN.md index 2b4f403..dbbf264 100644 --- a/README_CN.md +++ b/README_CN.md @@ -170,10 +170,10 @@ Function: Example: Client Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomDate \"YMD\"}}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ randomDate 'YMD' }}" -verbose 0 Body Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomDate \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ randomDate 'YMD' }}" -verbose 0 ``` **(4) 生成指定大小的随机字符串** @@ -212,10 +212,10 @@ Function: Example: Client Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ date \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090?data={{ date 'YMD' }}" -verbose 0 Body Request Example: -./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ date \"YMD\" }}" -verbose 0 +./http_bench -c 1 -n 1 "https://127.0.0.1:18090" -body "data={{ date 'YMD' }}" -verbose 0 ``` **(7) UUID标识(如果异常返回一个唯一随机字符串)** diff --git a/http_bench_test.go b/http_bench_test.go index 48ec3d6..eda88d8 100644 --- a/http_bench_test.go +++ b/http_bench_test.go @@ -352,6 +352,7 @@ func tcpHandleConnection(conn net.Conn) error { func TestStressTCP(t *testing.T) { name := "tcp" body := "this is stress body" + bodyHex := "746869732069732073747265737320626f6479" listen := "127.0.0.1:18091" srv, err := net.Listen("tcp", listen) if err != nil { @@ -389,7 +390,7 @@ func TestStressTCP(t *testing.T) { isErr: false, }, { - args: fmt.Sprintf(`-c 1 -d %ds -p %s -body "{{ stringToHex '%s' }}" -url %s`, duration, name, body, listen), + args: fmt.Sprintf(`-c 1 -d %ds -p %s -bodytype hex -body %s -url %s`, duration, name, bodyHex, listen), isErr: false, }, } { diff --git a/http_utils.go b/http_utils.go index bc1020f..c996a12 100644 --- a/http_utils.go +++ b/http_utils.go @@ -149,8 +149,7 @@ func hexToString(hexStr string) string { func stringToHex(s string) string { data := []byte(s) - hexStr := hex.EncodeToString(data) - return hexStr + return hex.EncodeToString(data) } func parseTime(timeStr string) int64 {