New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: add ServeContent #2039
Labels
Comments
From Andy Balholm: """ Thanks, Brad. I tried it out in my server, and it works. But now it exposes another problem: redirects. The fileHandler redirects requests for /index.html to / . But since it's running under StripPrefix, the user really requested /static/index.html (in this case), and he should be redirected to /static/ . It's easy enough to fix on my site, since I was redirecting / to /static/index.html already. I just redirected / to /static/ instead. (I really ought to eliminate the /static directory entirely, but that's another issue.) But I'm puzzled about how to fix it in the general case. Ideally, it would be nice to be able to fix redirects issued even by user code (not just by FileServer), but how would you do that? """ |
We currently have: 236 // ServeFile replies to the request with the contents of the named file or directory. 237 func ServeFile(w ResponseWriter, r *Request, name string) { 238 dir, file := filepath.Split(name) 239 serveFile(w, r, Dir(dir), file, false) 240 } ... where the FileSystem (Dir(dir)) cannot be controlled. This is the only path to serveFile. Can we export "serveFile" with some new non-conflicting name? |
Owner changed to builder@golang.org. |
http://golang.org/cl/5541059/ Status changed to Started. |
I think I could get behind // ServeContent replies to the request using the content of the reader r. // The main benefit of ServeContent over io.Copy is that it handles Range // requests properly. Note that *os.File implements the io.ReadSeeker interface. func ServeContent(w ResponseWriter, req *Request, r io.ReadSeeker) This does not have to be done before Go 1. Labels changed: added priority-later, removed priority-go1, go1-must. Status changed to Accepted. |
Owner changed to @bradfitz. Status changed to Started. |
This issue was closed by revision 4539d1f. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: