Commit ec3bac92 authored by Matt Bell's avatar Matt Bell

commands/http: client: Decode values into a new instance of the output type

parent e5171bf1
......@@ -150,11 +150,11 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
outChan := make(chan interface{})
go func() {
dec := json.NewDecoder(httpRes.Body)
outputType := reflect.ValueOf(req.Command().Type).Type()
v := reflect.New(outputType).Interface()
outputType := reflect.TypeOf(req.Command().Type)
for {
err := dec.Decode(&v)
v := reflect.New(outputType).Interface()
err := dec.Decode(v)
if err != nil && err != io.EOF {
fmt.Println(err.Error())
return
......@@ -199,8 +199,9 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
res.SetError(e, e.Code)
} else {
v := req.Command().Type
err = dec.Decode(&v)
outputType := reflect.TypeOf(req.Command().Type)
v := reflect.New(outputType).Interface()
err = dec.Decode(v)
if err != nil && err != io.EOF {
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment