Skip to content

Commit

Permalink
webdav: remove Go 1.6 support, use std context
Browse files Browse the repository at this point in the history
Fixes golang/go#21364

Change-Id: Ibfc6f5001d7038e4efd1f3fe8fc6d3fdded85551
Reviewed-on: https://go-review.googlesource.com/c/148438
Reviewed-by: Daniel Theophanes <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
bradfitz committed Nov 8, 2018
1 parent ccbb57f commit 04ba8c8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 52 deletions.
3 changes: 1 addition & 2 deletions webdav/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package webdav

import (
"context"
"encoding/xml"
"io"
"net/http"
Expand All @@ -14,8 +15,6 @@ import (
"strings"
"sync"
"time"

"golang.org/x/net/context"
)

// slashClean is equivalent to but slightly more efficient than
Expand Down
17 changes: 0 additions & 17 deletions webdav/file_go1.6.go

This file was deleted.

16 changes: 0 additions & 16 deletions webdav/file_go1.7.go

This file was deleted.

3 changes: 1 addition & 2 deletions webdav/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package webdav

import (
"context"
"encoding/xml"
"fmt"
"io"
Expand All @@ -18,8 +19,6 @@ import (
"strconv"
"strings"
"testing"

"golang.org/x/net/context"
)

func TestSlashClean(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions webdav/prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package webdav

import (
"bytes"
"context"
"encoding/xml"
"errors"
"fmt"
Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions webdav/prop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package webdav

import (
"context"
"encoding/xml"
"fmt"
"net/http"
Expand All @@ -13,8 +14,6 @@ import (
"regexp"
"sort"
"testing"

"golang.org/x/net/context"
)

func TestMemPS(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions webdav/webdav_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package webdav

import (
"context"
"errors"
"fmt"
"io"
Expand All @@ -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
Expand Down

0 comments on commit 04ba8c8

Please sign in to comment.