mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 00:39:31 +08:00
Merge pull request #1502 from ipfs/hotfix/nil-ctx
if no context set in request, use context.TODO()
This commit is contained in:
@ -13,6 +13,8 @@ import (
|
|||||||
|
|
||||||
cmds "github.com/ipfs/go-ipfs/commands"
|
cmds "github.com/ipfs/go-ipfs/commands"
|
||||||
config "github.com/ipfs/go-ipfs/repo/config"
|
config "github.com/ipfs/go-ipfs/repo/config"
|
||||||
|
|
||||||
|
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -35,6 +37,14 @@ func NewClient(address string) Client {
|
|||||||
|
|
||||||
func (c *client) Send(req cmds.Request) (cmds.Response, error) {
|
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
|
// save user-provided encoding
|
||||||
previousUserProvidedEncoding, found, err := req.Option(cmds.EncShort).String()
|
previousUserProvidedEncoding, found, err := req.Option(cmds.EncShort).String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user