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: FileServer with "/proc" directory doesn't work on Linux #10699
Comments
This is because the Linux I suppose we could never trust 0-length files and just serve them without a Content-Length, and also disable caching and Range and such. |
It's probably not worth it, but if the file is zero length you could call syscall.Statfs(path, &statfs) and check for statfs.Type == 0x9fa0 (aka PROC_SUPER_MAGIC, but syscall doesn't define that yet). For completeness you would also want to check for 0x62656572 (aka SYSFS_MAGIC) since the files under /sys also don't have the right length. |
I don't think I want to sniff for |
I think it's a mistake to do anything about this. Accessing such files through a web server is too dangerous to provide a general mechanism like this. |
I agree. You should have to go out of your way to do this. |
http.FileServer doesn't work with files in /proc on Linux. It gets the directories right, but files cannot be downloaded. They are returned with Content-Length: 0 instead.
I would prefer to get the content of the files.
Using go version go1.4.2
The text was updated successfully, but these errors were encountered: