Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly support commas in headers #165

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,10 @@ func Run() error {
if caCert, _ := GlobalFlags.GetString("rsh-ca-cert"); caCert != "" {
viper.Set("rsh-ca-cert", caCert)
}
if query, _ := GlobalFlags.GetStringSlice("rsh-query"); len(query) > 0 {
if query, _ := GlobalFlags.GetStringArray("rsh-query"); len(query) > 0 {
viper.Set("rsh-query", query)
}
if headers, _ := GlobalFlags.GetStringSlice("rsh-header"); len(headers) > 0 {
if headers, _ := GlobalFlags.GetStringArray("rsh-header"); len(headers) > 0 {
viper.Set("rsh-header", headers)
}
profile, _ := GlobalFlags.GetString("rsh-profile")
Expand Down
9 changes: 9 additions & 0 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ func TestPutURI400(t *testing.T) {
}`)
}

func TestHeaderWithComma(t *testing.T) {
defer gock.Off()

gock.New("http://example.com").Get("/").MatchHeader("Foo", "a,b,c").Reply(204)

out := run("http://example.com/ -H Foo:a,b,c")
assert.Contains(t, out, "204 No Content")
}

type TestAuth struct{}

// Parameters returns a list of OAuth2 Authorization Code inputs.
Expand Down
4 changes: 2 additions & 2 deletions cli/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func AddGlobalFlag(name, short, description string, defaultValue interface{}, mu
v = strings.Split(s, ",")
viper.Set(name, v)
}
flags.StringSliceP(name, short, v.([]string), description)
GlobalFlags.StringSliceP(name, short, v.([]string), description)
flags.StringArrayP(name, short, v.([]string), description)
GlobalFlags.StringArrayP(name, short, v.([]string), description)
} else {
flags.StringP(name, short, fmt.Sprintf("%v", viper.Get(name)), description)
GlobalFlags.StringP(name, short, fmt.Sprintf("%v", viper.Get(name)), description)
Expand Down