net/http: ServeContent If-None-Match will always NOT match #41536
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Making a curl passing If-None-Match does not work as documented
Do to a bug If-None-Match will always not match. This makes the If-None-Match check useless in http.ServeContent()
Example Curl
https://golang.org/pkg/net/http/#ServeContent
Documentation claims this function supports If-Match, If-None-Match, If-Range
Reviewing the code it appears this is not the case.
https://golang.org/src/net/http/fs.go?s=5158:5262#L145
func ServeContent calls serveContent
the third line of the function calls
checkPreconditions() then calls checkIfNoneMatch()
checkIfNoneMatch() at this point the 'w ResponseWriter' has no reference to the actual file so it's not possible to read the tag of the file. It will always be empty string ''.
You see the ** serveContent()** last input parameter is content io.ReadSeeker and the w ResponseWriter does not have any reference to it prior to calling checkIfNoneMatch() so its not possible to get the etag of the file to compare.
What did you expect to see?
If the file has not been modified and the etag matches a 304 (Not Modified) should be returned.
What did you see instead?
Instead ServeContent() returns the file because of the internal etag checking bug.
The text was updated successfully, but these errors were encountered: