Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

@rabisg
Copy link
Contributor

rabisg commented Jan 1, 2017

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:

  • Set Origin to be Client origin when client object is implemented in Request
  • Set Origin to null (OpaqueOrigin) when hyper supports it (This seems to be missing from the current implementation in hyper)

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14787
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

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
Copy link

highfive commented Jan 1, 2017

Heads up! This PR modifies the following files:

@rabisg rabisg force-pushed the rabisg:set-origin-header branch 2 times, most recently from 75f4077 to 234fd2d Jan 2, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Jan 2, 2017

The latest upstream changes (presumably #14784) made this pull request unmergeable. Please resolve the merge conflicts.

@KiChjang
Copy link
Member

KiChjang commented Jan 3, 2017

Sorry, but could you remove your merge commit and rebase against the master branch instead? We don't accept PRs that contain merge commits.

@rabisg rabisg force-pushed the rabisg:set-origin-header branch from 148ed45 to 2ff8d00 Jan 3, 2017
@rabisg
Copy link
Contributor Author

rabisg commented Jan 3, 2017

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
@rabisg rabisg force-pushed the rabisg:set-origin-header branch from 2ff8d00 to 010b937 Jan 3, 2017
@jdm jdm removed the S-needs-rebase label Jan 3, 2017
@jdm
Copy link
Member

jdm commented Jan 12, 2017

@wafflespeanut Review ping!

@wafflespeanut
Copy link
Member

wafflespeanut commented Jan 12, 2017

I don't even recall seeing this. Sorry, will review it in a bit :)

Copy link
Member

wafflespeanut left a comment

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.

@wafflespeanut

wafflespeanut Jan 12, 2017

Member

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

This comment has been minimized.

@wafflespeanut

wafflespeanut Jan 12, 2017

Member

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()) {

This comment has been minimized.

@wafflespeanut

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.

@wafflespeanut

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.

@wafflespeanut
Copy link
Member

wafflespeanut commented Jan 22, 2017

@rabisg Any plans to finish this off?

@jdm
Copy link
Member

jdm commented Feb 3, 2017

Closing due to lack of activity.

@jdm jdm closed this Feb 3, 2017
bors-servo added a commit that referenced this pull request Feb 15, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 16, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 17, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 18, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 20, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 21, 2017
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 -->
bors-servo added a commit that referenced this pull request Feb 24, 2017
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 -->
@ferjm ferjm mentioned this pull request Mar 9, 2017
4 of 4 tasks complete
bors-servo added a commit that referenced this pull request Mar 10, 2017
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 -->
bors-servo added a commit that referenced this pull request Mar 10, 2017
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.