Closed chrispassas closed 4 years ago
It looks like this bug goes all the way back to when ServeContent was added 2/9/2012, 6:02:06 PM by @bradfitz
On further review I've discovered the issue. In my own example the etag was being sent back from the server without double quotes around it.
It appears the Go http package will not work without the double quotes. I believe this is in spec for the RFC so I'm closing the issue.
For what its worth I think it would make sense for Go to support etags with/without double quotes.
For what its worth I think it would make sense for Go to support etags with/without double quotes.
@chrispassas please consider opening a new issue to discuss this.
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.