Skip to content

Commit 346cc61

Browse files
neildgopherbot
authored andcommitted
webdav: relax test to check for any redirect status, not just 301
CL 720820 changed net/http to use a 307 Temporary Redirect instead of a 301 Moved Permanently when performing an automatic redirect under some circumstances. Update tests in the webdav package to be agnostic on the exact redirect status code. Change-Id: I71784a738d18928a98387ddbd5475d50b19d15bf Reviewed-on: https://go-review.googlesource.com/c/net/+/723120 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Nicholas Husin <nsh@golang.org> Auto-Submit: Nicholas Husin <nsh@golang.org>
1 parent 9a29643 commit 346cc61

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

webdav/webdav_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,19 @@ func TestPrefix(t *testing.T) {
5353
return nil, err
5454
}
5555
defer res.Body.Close()
56-
if res.StatusCode != wantStatusCode {
56+
isRedirect := func(code int) bool {
57+
switch code {
58+
case http.StatusMovedPermanently,
59+
http.StatusTemporaryRedirect,
60+
http.StatusPermanentRedirect:
61+
return true
62+
default:
63+
return false
64+
}
65+
}
66+
if isRedirect(res.StatusCode) && isRedirect(wantStatusCode) {
67+
// Allow any redirect.
68+
} else if res.StatusCode != wantStatusCode {
5769
return nil, fmt.Errorf("got status code %d, want %d", res.StatusCode, wantStatusCode)
5870
}
5971
return res.Header, nil

0 commit comments

Comments
 (0)