Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFixes #14787: Set Origin header in http_network_or_cache_fetch #14811
Conversation
highfive
commented
Jan 1, 2017
|
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. |
highfive
commented
Jan 1, 2017
|
Heads up! This PR modifies the following files:
|
75f4077
to
234fd2d
|
|
|
Sorry, but could you remove your merge commit and rebase against the master branch instead? We don't accept PRs that contain merge commits. |
|
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
|
@wafflespeanut Review ping! |
|
I don't even recall seeing this. Sorry, will review it in a bit :) |
|
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 { |
This comment has been minimized.
This comment has been minimized.
| (*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 |
This comment has been minimized.
This comment has been minimized.
| 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()) { |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Jan 12, 2017
Member
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) { |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Jan 12, 2017
Member
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 -->
rabisg commentedJan 1, 2017
•
edited by larsbergstrom
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is