-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fixes #14787: Set Origin header in http_network_or_cache_fetch #14811
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @wafflespeanut (or someone else) soon. |
Heads up! This PR modifies the following files:
|
75f4077
to
234fd2d
Compare
☔ The latest upstream changes (presumably #14784) made this pull request unmergeable. Please resolve the merge conflicts. |
Sorry, but could you remove your merge commit and rebase against the master branch instead? We don't accept PRs that contain merge commits. |
148ed45
to
2ff8d00
Compare
Sorry was trying Github resolve conflict for the first time. Didn't realise it created a merge commit. Fixed that. |
Sets Origin header on request with CORS flag set or on requests other than those with GET/HEAD methods
2ff8d00
to
010b937
Compare
@wafflespeanut Review ping! |
I don't even recall seeing this. Sorry, will review it in a bit :) |
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.
Sorry for the delay in review. Just a few comments 😄
// TODO update this when https://github.com/hyperium/hyper/pull/691 is finished | ||
// http_request.headers.borrow_mut().set_raw("origin", origin); | ||
// Step 7 | ||
if http_request.omit_origin_header.get() == false { |
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.
Nit: This should be,
if !http_request.omit_origin_header.get() {
(*http_request.method.borrow() != Method::Get && *http_request.method.borrow() != Method::Head) { | ||
// TODO update this when https://github.com/hyperium/hyper/pull/691 is finished | ||
// http_request.headers.borrow_mut().set_raw("origin", origin); | ||
// Step 7 |
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.
This is step 9.
if cors_flag || (*method != Method::Get && *method != Method::Head) { | ||
match *http_request.origin.borrow() { | ||
Origin::Origin(ref url_origin) => | ||
match try_url_origin_to_hyper_origin(url_origin.clone()) { |
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.
We don't have to clone if we don't move anything from it. We can just pass the reference, deref it, and clone stuff only when needed. Also, this could be rewritten with if let
as,
if let Some(hyper_origin) = try_url_origin_to_hyper_origin(url_origin) {
//
}
// Step 7 | ||
if http_request.omit_origin_header.get() == false { | ||
let method = http_request.method.borrow(); | ||
if cors_flag || (*method != Method::Get && *method != Method::Head) { |
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.
According to the spec, the request's origin will be changed to "client"
during fetching. We should have a debug_assert!(*http_request.origin.borrow() != Origin::Client)
and go with if let
here.
@rabisg Any plans to finish this off? |
Closing due to lack of activity. |
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Fixes #14787 building on #14811: Set Origin header in http_network_or_cache_fetch Incorporates review feedback from #14811 I noticed that the "steps" in the comments don't necessarily correspond to the steps in the current fetch standard. This adds step 11 in the spec, but the steps commented in the implementation look wrong. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14787. - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15547) <!-- Reviewable:end -->
Allow for redirects after a CORS-preflight ~Continue the work done in #14811 and #15547~. And applies the Fetch [spec change](whatwg/fetch@0d9a4db) about [allowing redirects after CORS preflights](whatwg/fetch#204). - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix ~#14787 and~ #14519 - [X] There are tests for these changes. Several WPTs go from FAIL to SUCCESS. The new expected FAILs for the cors/redirect-preflight.htm tests are caused by the spec change done [here](whatwg/fetch@0d9a4db), as suggested in the associated [issue](#14519 (comment)). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15889) <!-- Reviewable:end -->
Allow for redirects after a CORS-preflight ~Continue the work done in #14811 and #15547~. And applies the Fetch [spec change](whatwg/fetch@0d9a4db) about [allowing redirects after CORS preflights](whatwg/fetch#204). - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix ~#14787 and~ #14519 - [X] There are tests for these changes. Several WPTs go from FAIL to SUCCESS. The new expected FAILs for the cors/redirect-preflight.htm tests are caused by the spec change done [here](whatwg/fetch@0d9a4db), as suggested in the associated [issue](#14519 (comment)). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15889) <!-- Reviewable:end -->
Sets Origin header on request with CORS flag set or on requests other
than those with GET/HEAD methods
There are 2 TODOs marked in the current implementation:
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is