]> Cypherpunks repositories - gostls13.git/commit
net/http: map FS Open errors just like Dir
authorJonathan Amsterdam <jba@google.com>
Sat, 8 Jan 2022 14:18:24 +0000 (09:18 -0500)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Mon, 10 Jan 2022 04:23:42 +0000 (04:23 +0000)
commit6df0957060b1315db4fd6a359eefc3ee92fcc198
tree82386b21670ecd53161040951b0f381782f7937e
parent2639f2f79bda2c3a4e9ef7381ca7de14935e2a4a
net/http: map FS Open errors just like Dir

When an http.FileServer is given a path like file1/file2 where file1
exists but file2 does not, the proper HTTP status should be
NotFound. Some OSes return a "not a directory" error instead, so this
must be mapped to NotFound.

That mapping was already being done for the Dir FileSystem
implementation, as discussed in #18984. But it wasn't for the
FS implementation.

This CL does the same mapping for FS, by generalizing the function
that did it for Dir.

Fixes #49552

Change-Id: I61d6aa8ef101158e9674707d44e653f5dedbd040
Reviewed-on: https://go-review.googlesource.com/c/go/+/376874
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/http/fs.go
src/net/http/fs_test.go