This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Set ETag header with correct syntax#714
Merged
Merged
Conversation
Contributor
|
This was my code and the change looks good to me. Good catch! |
Member
Author
|
@jpeletier Thank you, no problem. I would have missed that too for sure, so I learned something new. :) |
acud
approved these changes
Jun 13, 2018
holisticode
approved these changes
Jun 13, 2018
zelig
approved these changes
Jun 13, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR sets the ETag header with the right syntax (under double quotes) in order to stdlib's http.scanETag parse it correctly when it is provided as the value of If-Range http request header.
If If-Range http header is provided in request and the http.Request has ETag header (what is the case in HandleGet and HandleGetFile functions), http.ServeContent will try to match their values in order to validate the request's Range header. If values from request If-Range and response Etag are not matched, Request header value is discarded and the server wil serve the full content with response status code 200. This is currently happening when Chrome video player makes requests. It provides the ETag value from the previous request as the value for If-Range request header. Unfortunately, that value is required to be under double quotes to stdlib's http.scanETag parse it correctly. If it is not parsed correctly, it is considered as a no match forcing the full response, instead the partial one.
This change significantly improves the performance of video playback in Chrome.