diff --git a/backend_client.go b/backend_client.go index 882bc95..ce7ebd6 100644 --- a/backend_client.go +++ b/backend_client.go @@ -36,7 +36,6 @@ import ( "sync" "github.com/dlintw/goconf" - "golang.org/x/net/context/ctxhttp" ) var ( @@ -248,8 +247,14 @@ func performRequestWithRedirects(ctx context.Context, client *http.Client, req * req.Body = ioutil.NopCloser(bytes.NewReader(body)) req.ContentLength = int64(len(body)) } - resp, err = ctxhttp.Do(ctx, client, req) + resp, err = client.Do(req.WithContext(ctx)) if err != nil { + // Prefer context error if it has been cancelled. + select { + case <-ctx.Done(): + err = ctx.Err() + default: + } if e, ok := err.(*url.Error); !ok || resp == nil || e.Err != ErrUseLastResponse { return nil, err } diff --git a/go.mod b/go.mod index 4e1f03e..cdbed37 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,5 @@ require ( github.com/notedit/janus-go v0.0.0-20200517101215-10eb8b95d1a0 github.com/oschwald/maxminddb-golang v1.3.1-0.20190523235738-1960b16a5147 go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b - golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 gopkg.in/dgrijalva/jwt-go.v3 v3.2.0 ) diff --git a/virtualsession_test.go b/virtualsession_test.go index 11041b8..82de2de 100644 --- a/virtualsession_test.go +++ b/virtualsession_test.go @@ -22,10 +22,9 @@ package signaling import ( + "context" "encoding/json" "testing" - - "golang.org/x/net/context" ) func TestVirtualSession(t *testing.T) {