Commit 04ba8c85 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

webdav: remove Go 1.6 support, use std context

Fixes golang/go#21364

Change-Id: Ibfc6f5001d7038e4efd1f3fe8fc6d3fdded85551
Reviewed-on: https://go-review.googlesource.com/c/148438Reviewed-by: 's avatarDaniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ccbb57fb
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package webdav package webdav
import ( import (
"context"
"encoding/xml" "encoding/xml"
"io" "io"
"net/http" "net/http"
...@@ -14,8 +15,6 @@ import ( ...@@ -14,8 +15,6 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"golang.org/x/net/context"
) )
// slashClean is equivalent to but slightly more efficient than // slashClean is equivalent to but slightly more efficient than
......
// 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()
}
// 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()
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package webdav package webdav
import ( import (
"context"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io" "io"
...@@ -18,8 +19,6 @@ import ( ...@@ -18,8 +19,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
"golang.org/x/net/context"
) )
func TestSlashClean(t *testing.T) { func TestSlashClean(t *testing.T) {
......
...@@ -6,6 +6,7 @@ package webdav ...@@ -6,6 +6,7 @@ package webdav
import ( import (
"bytes" "bytes"
"context"
"encoding/xml" "encoding/xml"
"errors" "errors"
"fmt" "fmt"
...@@ -15,8 +16,6 @@ import ( ...@@ -15,8 +16,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"golang.org/x/net/context"
) )
// Proppatch describes a property update instruction as defined in RFC 4918. // Proppatch describes a property update instruction as defined in RFC 4918.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package webdav package webdav
import ( import (
"context"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"net/http" "net/http"
...@@ -13,8 +14,6 @@ import ( ...@@ -13,8 +14,6 @@ import (
"regexp" "regexp"
"sort" "sort"
"testing" "testing"
"golang.org/x/net/context"
) )
func TestMemPS(t *testing.T) { func TestMemPS(t *testing.T) {
......
...@@ -174,7 +174,7 @@ func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status ...@@ -174,7 +174,7 @@ func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status
if err != nil { if err != nil {
return status, err return status, err
} }
ctx := getContext(r) ctx := r.Context()
allow := "OPTIONS, LOCK, PUT, MKCOL" allow := "OPTIONS, LOCK, PUT, MKCOL"
if fi, err := h.FileSystem.Stat(ctx, reqPath); err == nil { if fi, err := h.FileSystem.Stat(ctx, reqPath); err == nil {
if fi.IsDir() { if fi.IsDir() {
...@@ -197,7 +197,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta ...@@ -197,7 +197,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
return status, err return status, err
} }
// TODO: check locks for read-only access?? // TODO: check locks for read-only access??
ctx := getContext(r) ctx := r.Context()
f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDONLY, 0) f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDONLY, 0)
if err != nil { if err != nil {
return http.StatusNotFound, err return http.StatusNotFound, err
...@@ -231,7 +231,7 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i ...@@ -231,7 +231,7 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i
} }
defer release() defer release()
ctx := getContext(r) ctx := r.Context()
// TODO: return MultiStatus where appropriate. // TODO: return MultiStatus where appropriate.
...@@ -262,7 +262,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int, ...@@ -262,7 +262,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
defer release() defer release()
// TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz' // TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz'
// comments in http.checkEtag. // 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) f, err := h.FileSystem.OpenFile(ctx, reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil { if err != nil {
...@@ -300,7 +300,7 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status in ...@@ -300,7 +300,7 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status in
} }
defer release() defer release()
ctx := getContext(r) ctx := r.Context()
if r.ContentLength > 0 { if r.ContentLength > 0 {
return http.StatusUnsupportedMediaType, nil return http.StatusUnsupportedMediaType, nil
...@@ -344,7 +344,7 @@ func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status ...@@ -344,7 +344,7 @@ func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status
return http.StatusForbidden, errDestinationEqualsSource return http.StatusForbidden, errDestinationEqualsSource
} }
ctx := getContext(r) ctx := r.Context()
if r.Method == "COPY" { if r.Method == "COPY" {
// Section 7.5.1 says that a COPY only needs to lock the destination, // Section 7.5.1 says that a COPY only needs to lock the destination,
...@@ -399,7 +399,7 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus ...@@ -399,7 +399,7 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus
return status, err return status, err
} }
ctx := getContext(r) ctx := r.Context()
token, ld, now, created := "", LockDetails{}, time.Now(), false token, ld, now, created := "", LockDetails{}, time.Now(), false
if li == (lockInfo{}) { if li == (lockInfo{}) {
// An empty lockInfo means to refresh the lock. // An empty lockInfo means to refresh the lock.
...@@ -511,7 +511,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status ...@@ -511,7 +511,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
if err != nil { if err != nil {
return status, err return status, err
} }
ctx := getContext(r) ctx := r.Context()
fi, err := h.FileSystem.Stat(ctx, reqPath) fi, err := h.FileSystem.Stat(ctx, reqPath)
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
...@@ -581,7 +581,7 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu ...@@ -581,7 +581,7 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu
} }
defer release() defer release()
ctx := getContext(r) ctx := r.Context()
if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil { if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package webdav package webdav
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"io" "io"
...@@ -18,8 +19,6 @@ import ( ...@@ -18,8 +19,6 @@ import (
"sort" "sort"
"strings" "strings"
"testing" "testing"
"golang.org/x/net/context"
) )
// TODO: add tests to check XML responses with the expected prefix path // TODO: add tests to check XML responses with the expected prefix path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment