git » gofer » commit 1923d66

test: Update ServeMux directory redirects from status 301 to 307

author Alberto Bertogli
2026-03-04 23:23:54 UTC
committer Alberto Bertogli
2026-03-04 23:27:54 UTC
parent 514b23d9a484b2b414eb03288165d6be9a341fe4

test: Update ServeMux directory redirects from status 301 to 307

In Go 1.26, the http.ServeMux behaviour was changed on some redirects
(e.g. /dir -> /dir/) to return 307 Temporary Redirect (instead of the
previous 301 Moved Permanently).

This happened in Go commit 831af61120b9b846965996ed1d4daaa079847b2a
(2025-11-15, "net/http: use HTTP 307 redirects in ServeMux").

So this patch updates the tests accordingly.

.github/workflows/tests.yaml +1 -1
test/test.sh +4 -4

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 209a7f2..55f73e2 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -17,7 +17,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: actions/setup-go@v3
         with:
-          go-version: ">=1.20"
+          go-version: ">=1.26"
       - name: install cue
         run: go install cuelang.org/go/cmd/cue@latest
       - name: install goveralls
diff --git a/test/test.sh b/test/test.sh
index a829ecc..89e0e0a 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -99,7 +99,7 @@ do
 	echo "### Common tests for $base"
 	exp $base/file -body "ñaca\n"
 
-	exp $base/dir -status 301 -redir /dir/
+	exp $base/dir -status 307 -redir /dir/
 
 	exp $base/dir/ -bodyre '<a href="%C3%B1aca">ñaca</a>'
 	exp $base/dir/ -bodyre '<a href="%23anchor">#anchor</a>'
@@ -159,7 +159,7 @@ do
 	# Files in authdir/; only some are covered by auth.
 	exp $base/authdir/hola -body 'hola marola\n'
 	exp $base/authdir/ñaca -status 401
-	exp $base/authdir/withoutindex -status 301
+	exp $base/authdir/withoutindex -status 307
 	exp $base/authdir/withoutindex/ -status 401
 	exp $base/authdir/withoutindex/chau -status 401
 
@@ -185,7 +185,7 @@ do
 	echo "### Good auth for $base"
 	exp $base/authdir/hola -body 'hola marola\n'
 	exp $base/authdir/ñaca -body "tracañaca\n"
-	exp $base/authdir/withoutindex -status 301
+	exp $base/authdir/withoutindex -status 307
 	exp $base/authdir/withoutindex/ -status 404
 	exp $base/authdir/withoutindex/chau -body 'chau\n'
 done
@@ -200,7 +200,7 @@ do
 	echo "### Bad auth for $base"
 	exp $base/authdir/hola -body 'hola marola\n'
 	exp $base/authdir/ñaca -status 401
-	exp $base/authdir/withoutindex -status 301
+	exp $base/authdir/withoutindex -status 307
 	exp $base/authdir/withoutindex/ -status 401
 	exp $base/authdir/withoutindex/chau -status 401
 done