]> Cypherpunks.ru repositories - gostls13.git/commit
net/http: mention io.Seeker requirement in FS documentation
authorAlex Studer <alex@studer.dev>
Wed, 20 Oct 2021 19:18:03 +0000 (19:18 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 26 Aug 2022 18:05:21 +0000 (18:05 +0000)
commitafd792feb567f0848ddc05f6a90a7b7672fe4974
treed8f600630ecaef28bdb6de101fb758b3d7ec4ca3
parent4d13aabdf62a15d19a6f41a781aa7e85f02f3f26
net/http: mention io.Seeker requirement in FS documentation

Both FileServer and NewFileTransport can try to seek a file, specifically
when MIME type sniffing is performed. This can be somewhat surprising to an
implementer of an fs.FS, as their filesystem will appear to work until a
user tries to access a file with an unrecognized extension (which requires
type sniffing and therefore seeking). With FileServer, this results in a
"seeker can't seek" message, which is not very clear for the developer.

The issue arises because fs.FS does not require Seek, while http.FileSystem
does. Therefore, this change adds a line to the documentation of net/http's
adapter function mentioning the requirement.

Change-Id: Ieb955b7a7f34e2be39dd696cb712513c70100b3a
GitHub-Last-Rev: fddccdae36e04fcb87d78b3b03fa4658dbb7d83d
GitHub-Pull-Request: golang/go#48781
Reviewed-on: https://go-review.googlesource.com/c/go/+/353874
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/net/http/fs.go