-
Notifications
You must be signed in to change notification settings - Fork 851
fix: properly process If-Range headers in client requests #8741
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
Conversation
|
@ezelkow1 can you kick off ci for this pr? |
|
[approve ci] |
proxy/http/HttpTransactCache.cc
Outdated
| bool | ||
| HttpTransactCache::validate_ifrange_header_if_any(HTTPHdr *request, HTTPHdr *response) | ||
| { | ||
| if (!(request->presence(MIME_PRESENCE_RANGE) && request->presence(MIME_PRESENCE_IF_RANGE))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is MIME_PRESENCE_RANGE checked here, when it's already been checked at both call sites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only meant as a precautionary measure. Should I turn it into an assertion, or would it be better to remove it completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove with a comment if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this in e0d44d7.
|
Looks good overall. Excellent description! |
|
I've been trying to recreate the issue and I just ran the autests in this PR against master without this PR and they all pass. Did some other PR already fix this? |
|
I tried reproducing this again, and it looks like the reproduction steps were insufficient. It looks like I need to set |
|
[approve ci autest] |
|
#8657 might've affected the test result, assuming that the CI does a merge with the current master branch before running the them. I'll try rebasing this PR. |
|
Anything new on this PR? |
ad16518 to
24dc54e
Compare
24dc54e to
c1ea24a
Compare
|
Sorry for the delay. I've rebased and tweaked the changes against the master branch. It turns out #8657 did change a few things, but the same issue still persists. Now instead of |
traeak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything looks okay
traeak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
* fix: properly process If-Range headers in client requests * chore: add autest for range requests * refactor: only check the presence of Range headers once
Problem
ATS doesn't respond correctly to conditional range requests. According to the spec, ATS must ignore the
Rangeheader and send back the full content when the condition in theIf-Rangeheader isn't satisified. ATS responds with416 Requested Range Not Satisfiableinstead.How to reproduce
curl -vv http://localhost)curl -vv -H 'If-Range: W/"this_wont_match"' http://localhost)Cause
ATS validates
If-Rangeheaders inmatch_response_to_request_conditionals(). If the condition specified inIf-Rangeisn't met,match_response_to_request_conditionals()returns a response code ofHTTP_STATUS_RANGE_NOT_SATISFIABLE. However, ATS can't determine whether aHTTP_STATUS_RANGE_NOT_SATISFIABLEresponse code came frommatch_response_to_request_conditionals()or the response of the original content. This confusion led ATS to return incorrect responses to conditional range requests.Changes made
If-Rangeheader validation code out ofmatch_response_to_request_conditionals()so that it would run right before processing theRangeheader. This makes it easier to determine the correct response.