mirror of
https://github.com/golang/net.git
synced 2026-03-31 10:27:08 +09:00
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>
This commit is contained in:
committed by
Gopher Robot
parent
9a296438e5
commit
346cc6157e
@@ -53,7 +53,19 @@ func TestPrefix(t *testing.T) {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != wantStatusCode {
|
||||
isRedirect := func(code int) bool {
|
||||
switch code {
|
||||
case http.StatusMovedPermanently,
|
||||
http.StatusTemporaryRedirect,
|
||||
http.StatusPermanentRedirect:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
if isRedirect(res.StatusCode) && isRedirect(wantStatusCode) {
|
||||
// Allow any redirect.
|
||||
} else if res.StatusCode != wantStatusCode {
|
||||
return nil, fmt.Errorf("got status code %d, want %d", res.StatusCode, wantStatusCode)
|
||||
}
|
||||
return res.Header, nil
|
||||
|
||||
Reference in New Issue
Block a user