I am writting a simple test using http package. I use http.ServeFile
to handle static html files.
I got a strange question when the url match "index.html".
For example:
I have this httpserv running with a subdir "static" (which has a lot
html files).
func StaticFileServer(c *http.Conn, req *http.Request) {
http.ServeFile(c, req, "static"+req.URL.Path);
}
...
...
in main:
http.Handle("/", http.HandlerFunc(StaticFileServer));
when I request
http://localhost/, the server returned static/
index.html. It's ok.
when I request
http://localhost/index.html, the server just redirect
to
http://localhost/static/ -- it's not what I want.
Why doing so ?
I checked src/pkg/http/fs.go, and found that in func
serveFileInternal, it would always redirect the url ending with "/
index.html".
Is this redirect necessary ? I think it's not, or someone please
fixme.
my version `hg log -l 1`:
4199:67d92d7e6694