New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: Broken If-Range handling in ServeFile and friends unless caller sets ETag manually #8367
Labels
Milestone
Comments
This issue also was a problem for us, did workaround by modifying net/http/fs.go locally. The issue is that Chrome/ium sends a date in If-Range and that causes net/http/fs.go to zero the Range. Around line 300 in fs.go there is a TODO about this. Occurs in e.g. seeking large mp4 files with html5 videos. |
Let me try to re-summarize this bug more succinctly, without attachments. Please correct me if this is wrong (or confirm if this is correct). Browsers may send an If-Range header containing either an ETag or a date: http://tools.ietf.org/html/rfc7233#section-3.2 .... If-Range = entity-tag / HTTP-date .... The Go code only deals with the entity-tag half, and in fact has a comment about nobody seeming to care about sending a date, and the spec being unclear. From fs.go: if ir := r.Header.get("If-Range"); ir != "" && ir != etag { // TODO(bradfitz): handle If-Range requests with Last-Modified // times instead of ETags? I'd rather not, at least for // now. That seems like a bug/compromise in the RFC 2616, and // I've never heard of anybody caring about that (yet). rangeReq = "" } I like the "yet" part. That time apparently is now and Chrome does send a date in If-Range if the handler never sent an ETag. Note that the comment is discussing RFC 2616, and not the clarification RFC 7233. For reference, 2616 said: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.27 I'd rather not get into the business of guessing ETags for users. Maybe for on-disk files that's acceptable, but it should be a separate bug. For this bug, I think simply accepting an If-Range date matching the Last-Modified time should be an acceptable fix. Status changed to Accepted. |
Yes, the point of the attachments was purely to demonstrate that this is not a theoretical concern: net/http cannot serve html5 video without workarounds, currently. ServeFile is already talking about on-disk files, so I don't see why an ETag *there* would actively hurt. I don't think net/http should provide ETags for just any resource. |
ServeFile is a thin wrapper around ServeContent. The missing If-Range date handling is in ServeContent. Adding ETag in the way proposed could actively hurt: imagine a load-balanced environment with Go servers on many backends with different filesystems. The inode number could differ and cause problems if mixed in to the ETag. Again, please open a separate bug for that if you feel strongly and it can be discussed or designed separately. This bug should be about the date handling only. |
CL https://golang.org/cl/116300044 mentions this issue. |
This issue was closed by revision f5037ee. Status changed to Fixed. |
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Fixes golang#8367 LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/116300044
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Fixes golang#8367 LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/116300044
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Attachments:
The text was updated successfully, but these errors were encountered: