allow auth to have normal separater

master
Bel LaPointe 2020-02-26 14:16:14 -07:00
parent e05a287e4c
commit ca9c1b5f7c
1 changed files with 10 additions and 1 deletions

11
main.go Normal file → Executable file
View File

@ -35,7 +35,7 @@ func Main() error {
var bodyRepeat int
var path, host, method, body, headers, brandID, userID, issuer, basicAuth, claims string
var ca, cert, key, secret string
var needJWT, verbose, jsonPP bool
var needJWT, verbose, jsonPP, quiet bool
var timeout, lag time.Duration
flag.StringVar(&method, "method", "get", "method for request")
flag.StringVar(&path, "path", "fieldsetdefinitions/v1/index/surveys/SV_031sm3MMOPSa8Tz/fieldsets?assumeHasPermission=true", "path for request")
@ -50,6 +50,7 @@ func Main() error {
flag.BoolVar(&needJWT, "jwt", true, "need jwt boolean")
flag.BoolVar(&jsonPP, "jpp", true, "try json pretty print")
flag.BoolVar(&verbose, "v", false, "is verbose")
flag.BoolVar(&quiet, "q", false, "is quiet")
flag.DurationVar(&timeout, "t", time.Second*10, "request timeout")
flag.DurationVar(&lag, "lag", time.Second*0, "writing request lag after connecting")
flag.StringVar(&ca, "ca", "", "ca for server")
@ -59,6 +60,11 @@ func Main() error {
flag.StringVar(&claims, "claims", "", "extra claims as k=v,k=v")
flag.Parse()
if quiet {
f, _ := ioutil.TempFile(os.TempDir(), "*")
os.Stderr = f
}
if !strings.HasPrefix(host, "http") {
host = "http://" + host
}
@ -92,6 +98,9 @@ func Main() error {
}
if basicAuth != "" {
splits := strings.Split(basicAuth, ",")
if len(splits) == 1 {
splits = strings.Split(basicAuth, ":")
}
req.SetBasicAuth(splits[0], splits[1])
}