mirror of
https://github.com/golang/net.git
synced 2026-03-31 10:27:08 +09:00
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>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -14,8 +15,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// slashClean is equivalent to but slightly more efficient than
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -18,8 +19,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestSlashClean(t *testing.T) {
|
||||
|
||||
@@ -6,6 +6,7 @@ package webdav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -15,8 +16,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Proppatch describes a property update instruction as defined in RFC 4918.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -13,8 +14,6 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestMemPS(t *testing.T) {
|
||||
|
||||
@@ -174,7 +174,7 @@ func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status
|
||||
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 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
|
||||
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 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i
|
||||
}
|
||||
defer release()
|
||||
|
||||
ctx := getContext(r)
|
||||
ctx := r.Context()
|
||||
|
||||
// TODO: return MultiStatus where appropriate.
|
||||
|
||||
@@ -262,7 +262,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
|
||||
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 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status in
|
||||
}
|
||||
defer release()
|
||||
|
||||
ctx := getContext(r)
|
||||
ctx := r.Context()
|
||||
|
||||
if r.ContentLength > 0 {
|
||||
return http.StatusUnsupportedMediaType, nil
|
||||
@@ -344,7 +344,7 @@ func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status
|
||||
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 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus
|
||||
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 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
|
||||
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 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu
|
||||
}
|
||||
defer release()
|
||||
|
||||
ctx := getContext(r)
|
||||
ctx := r.Context()
|
||||
|
||||
if _, err := h.FileSystem.Stat(ctx, reqPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -18,8 +19,6 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// TODO: add tests to check XML responses with the expected prefix path
|
||||
|
||||
Reference in New Issue
Block a user