net/http: document that the fs.FS passed to ServeFileFS, FileServerFS, and NewFileTransportFS must implement io.Seeker #66877
Labels
Documentation
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
The
fs.FS
argument, passed to the functionshttp.ServeFileFS
,http.FileServerFS
, andhttp.NewFileTransportFS
, must implementio.Seeker
. However, this requirement is not documented in these functions.If
io.Seeker
is not implemented, these functions may fail to serve files and instead could send a 500 error to the client. Here is the code from theserveContent
function where the error is returned:go/src/net/http/fs.go
Lines 248 to 252 in 2073b35
This error can be tricky to detect as it only appears if the "Content-Type" header of the response hasn’t been set earlier.
Note that the issue #44553 is similar, but unlike the current issue, it identifies it as a problem in the
serveContent
and suggests changing it.The text was updated successfully, but these errors were encountered: