if no context set in request, use context.TODO()
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jul 20, 2015 at 21:46 UTC
5873aa2aaa441b438183675d6dcff20a68e199a8
1 file changed
+10
commands/http/client.go
+10
@@ -13,6 +13,8 @@ import (
13
14
cmds "github.com/ipfs/go-ipfs/commands"
15
config "github.com/ipfs/go-ipfs/repo/config"
16
+
17
+ context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
18
)
19
20
const (
@@ -35,6 +37,14 @@ func NewClient(address string) Client {
37
38
func (c *client) Send(req cmds.Request) (cmds.Response, error) {
39
40
+ if req.Context() == nil {
41
+ log.Warningf("no context set in request")
42
+ err := req.SetRootContext(context.TODO())
43
+ if err != nil {
44
+ return nil, err
45
+ }
46
+ }
47
+
48
// save user-provided encoding
49
previousUserProvidedEncoding, found, err := req.Option(cmds.EncShort).String()
50
if err != nil {