webdav: remove Go 1.6 support, use std context

Fixes golang/go#21364

Change-Id: Ibfc6f5001d7038e4efd1f3fe8fc6d3fdded85551
Reviewed-on: https://go-review.googlesource.com/c/148438
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/webdav/file.go b/webdav/file.go
index 748118d..9f53778 100644
--- a/webdav/file.go
+++ b/webdav/file.go
@@ -5,6 +5,7 @@
 package webdav
 
 import (
+	"context"
 	"encoding/xml"
 	"io"
 	"net/http"
@@ -14,8 +15,6 @@
 	"strings"
 	"sync"
 	"time"
-
-	"golang.org/x/net/context"
 )
 
 // slashClean is equivalent to but slightly more efficient than
diff --git a/webdav/file_go1.6.go b/webdav/file_go1.6.go
deleted file mode 100644
index fa38770..0000000
--- a/webdav/file_go1.6.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.7
-
-package webdav
-
-import (
-	"net/http"
-
-	"golang.org/x/net/context"
-)
-
-func getContext(r *http.Request) context.Context {
-	return context.Background()
-}
diff --git a/webdav/file_go1.7.go b/webdav/file_go1.7.go
deleted file mode 100644
index d1c3de8..0000000
--- a/webdav/file_go1.7.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.7
-
-package webdav
-
-import (
-	"context"
-	"net/http"
-)
-
-func getContext(r *http.Request) context.Context {
-	return r.Context()
-}
diff --git a/webdav/file_test.go b/webdav/file_test.go
index bfd96e1..04b8a45 100644
--- a/webdav/file_test.go
+++ b/webdav/file_test.go
@@ -5,6 +5,7 @@
 package webdav
 
 import (
+	"context"
 	"encoding/xml"
 	"fmt"
 	"io"
@@ -18,8 +19,6 @@
 	"strconv"
 	"strings"
 	"testing"
-
-	"golang.org/x/net/context"
 )
 
 func TestSlashClean(t *testing.T) {
diff --git a/webdav/prop.go b/webdav/prop.go
index 4d7be34..2c48bc4 100644
--- a/webdav/prop.go
+++ b/webdav/prop.go
@@ -6,6 +6,7 @@
 
 import (
 	"bytes"
+	"context"
 	"encoding/xml"
 	"errors"
 	"fmt"
@@ -15,8 +16,6 @@
 	"os"
 	"path/filepath"
 	"strconv"
-
-	"golang.org/x/net/context"
 )
 
 // Proppatch describes a property update instruction as defined in RFC 4918.
diff --git a/webdav/prop_test.go b/webdav/prop_test.go
index bc42b91..855446b 100644
--- a/webdav/prop_test.go
+++ b/webdav/prop_test.go
@@ -5,6 +5,7 @@
 package webdav
 
 import (
+	"context"
 	"encoding/xml"
 	"fmt"
 	"net/http"
@@ -13,8 +14,6 @@
 	"regexp"
 	"sort"
 	"testing"
-
-	"golang.org/x/net/context"
 )
 
 func TestMemPS(t *testing.T) {
diff --git a/webdav/webdav.go b/webdav/webdav.go
index 7b56687..744d2d5 100644
--- a/webdav/webdav.go
+++ b/webdav/webdav.go
@@ -174,7 +174,7 @@
 	if err != nil {
 		return status, err
 	}
-	ctx := getContext(r)
+	ctx := r.Context()
 	allow := "OPTIONS, LOCK, PUT, MKCOL"
 	if fi, err := h.FileSystem.Stat(ctx, reqPath); err == nil {
 		if fi.IsDir() {
@@ -197,7 +197,7 @@
 		return status, err
 	}
 	// TODO: check locks for read-only access??
-	ctx := getContext(r)
+	ctx := r.Context()
 	f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDONLY, 0)
 	if err != nil {
 		return http.StatusNotFound, err
@@ -231,7 +231,7 @@
 	}
 	defer release()
 
-	ctx := getContext(r)
+	ctx := r.Context()
 
 	// TODO: return MultiStatus where appropriate.
 
@@ -262,7 +262,7 @@
 	defer release()
 	// TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz'
 	// comments in http.checkEtag.
-	ctx := getContext(r)
+	ctx := r.Context()
 
 	f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
 	if err != nil {
@@ -300,7 +300,7 @@
 	}
 	defer release()
 
-	ctx := getContext(r)
+	ctx := r.Context()
 
 	if r.ContentLength > 0 {
 		return http.StatusUnsupportedMediaType, nil
@@ -344,7 +344,7 @@
 		return http.StatusForbidden, errDestinationEqualsSource
 	}
 
-	ctx := getContext(r)
+	ctx := r.Context()
 
 	if r.Method == "COPY" {
 		// Section 7.5.1 says that a COPY only needs to lock the destination,
@@ -399,7 +399,7 @@
 		return status, err
 	}
 
-	ctx := getContext(r)
+	ctx := r.Context()
 	token, ld, now, created := "", LockDetails{}, time.Now(), false
 	if li == (lockInfo{}) {
 		// An empty lockInfo means to refresh the lock.
@@ -511,7 +511,7 @@
 	if err != nil {
 		return status, err
 	}
-	ctx := getContext(r)
+	ctx := r.Context()
 	fi, err := h.FileSystem.Stat(ctx, reqPath)
 	if err != nil {
 		if os.IsNotExist(err) {
@@ -581,7 +581,7 @@
 	}
 	defer release()
 
-	ctx := getContext(r)
+	ctx := r.Context()
 
 	if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil {
 		if os.IsNotExist(err) {
diff --git a/webdav/webdav_test.go b/webdav/webdav_test.go
index 25e0d54..46d1bb6 100644
--- a/webdav/webdav_test.go
+++ b/webdav/webdav_test.go
@@ -5,6 +5,7 @@
 package webdav
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"io"
@@ -18,8 +19,6 @@
 	"sort"
 	"strings"
 	"testing"
-
-	"golang.org/x/net/context"
 )
 
 // TODO: add tests to check XML responses with the expected prefix path