diff --git a/commands/http/client.go b/commands/http/client.go index 7a35c1a26..35aa59ca3 100644 --- a/commands/http/client.go +++ b/commands/http/client.go @@ -49,8 +49,15 @@ func Send(req cmds.Request) (cmds.Response, error) { } args := req.Arguments() + argDefs := req.Command().Arguments + var argDef cmds.Argument + for i, arg := range args { - if req.Command().Arguments[i].Type == cmds.ArgString { + if i < len(argDefs) { + argDef = argDefs[i] + } + + if argDef.Type == cmds.ArgString { query += "&arg=" + arg.(string) } else { diff --git a/commands/http/parse.go b/commands/http/parse.go index d55fffdd8..b30ef0bfd 100644 --- a/commands/http/parse.go +++ b/commands/http/parse.go @@ -36,17 +36,18 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) { // Note that the argument handling here is dumb, it does not do any error-checking. // (Arguments are further processed when the request is passed to the command to run) - args := make([]interface{}, len(cmd.Arguments)) - for i, arg := range cmd.Arguments { + args := make([]interface{}, 0) + + for _, arg := range cmd.Arguments { if arg.Type == cmds.ArgString { - if len(stringArgs) > 0 { - args[i] = stringArgs[0] + for j := 0; len(stringArgs) > 0 && arg.Variadic || j == 0; j++ { + args = append(args, stringArgs[0]) stringArgs = stringArgs[1:] } } else { // TODO: create multipart streams for file args - args[i] = r.Body + args = append(args, r.Body) } }