1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 03:28:25 +08:00

commands/http: client: Fixed decoding values in channel output

This commit is contained in:
Matt Bell
2015-01-05 14:19:13 -08:00
parent 981f793df9
commit ecc2248aa0

View File

@ -7,6 +7,7 @@ import (
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"reflect"
"strings" "strings"
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
@ -149,7 +150,8 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
outChan := make(chan interface{}) outChan := make(chan interface{})
go func() { go func() {
dec := json.NewDecoder(httpRes.Body) dec := json.NewDecoder(httpRes.Body)
v := req.Command().Type outputType := reflect.ValueOf(req.Command().Type).Type()
v := reflect.New(outputType).Interface()
for { for {
err := dec.Decode(&v) err := dec.Decode(&v)