1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-27 16:07:42 +08:00

if no context set in request, use context.TODO()

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-07-20 21:46:51 -07:00
parent 9978caf6f3
commit 5873aa2aaa

View File

@ -13,6 +13,8 @@ import (
cmds "github.com/ipfs/go-ipfs/commands"
config "github.com/ipfs/go-ipfs/repo/config"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
const (
@ -35,6 +37,14 @@ func NewClient(address string) Client {
func (c *client) Send(req cmds.Request) (cmds.Response, error) {
if req.Context() == nil {
log.Warningf("no context set in request")
err := req.SetRootContext(context.TODO())
if err != nil {
return nil, err
}
}
// save user-provided encoding
previousUserProvidedEncoding, found, err := req.Option(cmds.EncShort).String()
if err != nil {