diff options
| author | Shulhan <ms@kilabit.info> | 2026-02-05 19:26:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-02-05 19:26:29 +0700 |
| commit | 3734420eec485bca8c18243741e1ad2a683515b7 (patch) | |
| tree | c08f208e76f516048e07e982fa712daafc98cce3 /lib/http/testdata/Server_HandleFS_test.txt | |
| parent | f40153cfb1cd859538aeaad17f0a243b4ef0c52c (diff) | |
| download | pakakeh.go-3734420eec485bca8c18243741e1ad2a683515b7.tar.xz | |
lib/http: handle file system with canonical directory end with slash "/"
Previously, if request to directory does not end with "/", the HTTP
server will return the index.html of that directory.
This cause relative link inside the index.html broken when visited from
browser.
This changes make the request to directory always end with "/" by
redirecting the request with status 303 Found.
Diffstat (limited to 'lib/http/testdata/Server_HandleFS_test.txt')
| -rw-r--r-- | lib/http/testdata/Server_HandleFS_test.txt | 98 |
1 files changed, 85 insertions, 13 deletions
diff --git a/lib/http/testdata/Server_HandleFS_test.txt b/lib/http/testdata/Server_HandleFS_test.txt index 1089121a..8b2173ef 100644 --- a/lib/http/testdata/Server_HandleFS_test.txt +++ b/lib/http/testdata/Server_HandleFS_test.txt @@ -1,21 +1,93 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> -<<< TestServer_HandleFS/OnEmptyRoot +<<< / HTTP/1.1 200 OK Connection: close Content-Type: text/html; charset=utf-8 -<!DOCTYPE html><html> -<head> -<meta name="viewport" content="width=device-width"> -<style> -body{font-family:monospace; white-space:pre;} -</style> -</head> -<body> -<h3>Index of /</h3> -</body></html> +<!doctype html> +<html> + <head> + <title>/index.html</title> + </head> +</html> + +<<< /dir +HTTP/1.1 302 Found +Connection: close +Content-Type: text/html; charset=utf-8 +Location: /dir/ + +<a href="/dir/">Found</a>. + + + +<<< /dir?q=abc +HTTP/1.1 302 Found +Connection: close +Content-Type: text/html; charset=utf-8 +Location: /dir/?q=abc + +<a href="/dir/?q=abc">Found</a>. + + + +<<< /dir?q=abc#fgh +HTTP/1.1 302 Found +Connection: close +Content-Type: text/html; charset=utf-8 +Location: /dir/?q=abc#fgh + +<a href="/dir/?q=abc#fgh">Found</a>. + + + +<<< /dir/#fgh +HTTP/1.1 404 Not Found +Connection: close + + + +<<< /dir/ +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html; charset=utf-8 + +<!doctype html> +<html> + <head> + <title>/dir/index.html</title> + </head> +</html> + + +<<< /b +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html; charset=utf-8 + +<!doctype html> +<html> + <head> + <title>/b.html</title> + </head> +</html> + + +<<< /b?q=abc +HTTP/1.1 200 OK +Connection: close +Content-Type: text/html; charset=utf-8 + +<!doctype html> +<html> + <head> + <title>/b.html</title> + </head> +</html> + + <<< TestServer_HandleFS/OnNewDirectory HTTP/1.1 200 OK @@ -30,6 +102,6 @@ body{font-family:monospace; white-space:pre;} </style> </head> <body> -<h3>Index of /</h3> -<div>drwxr-xr-x <tt> 0</tt> 0000-00-00T00:00:00Z <a href="/dirA">dirA</a></div><br/> +<h3>Index of newDir</h3> +<div><a href='..'>..</a></div><br/> </body></html> |
