From 5873aa2aaa441b438183675d6dcff20a68e199a8 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 20 Jul 2015 21:46:51 -0700 Subject: [PATCH] if no context set in request, use context.TODO() License: MIT Signed-off-by: Jeromy --- commands/http/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commands/http/client.go b/commands/http/client.go index 9d21c9d5e..cebdc314b 100644 --- a/commands/http/client.go +++ b/commands/http/client.go @@ -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 {