Repository navigation
Update fetch methods - #17521
Update fetch methods#17521
Conversation
|
Heads up! This PR modifies the following files:
|
|
|
||
| if (same_origin && !cors_flag ) || | ||
| current_url.scheme() == "data" || | ||
| current_url.scheme() == "file" || |
There was a problem hiding this comment.
I am 99% sure this is going to hit the same problem as #14515 (comment) .
There was a problem hiding this comment.
How unfortunate. Looks like I'll have to drop those changes then.
|
Huh... looks like this update failed some unit tests, will look into them. |
927d099 to
81fa345
Compare
|
@bors-servo try |
Update fetch methods Includes updates to main fetch, scheme fetch, HTTP fetch, HTTP-redirect fetch, HTTP-network fetch, HTTP-network-or-cache fetch and CORS preflight fetch. <!-- 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/17521) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-wpt |
|
I found out what's wrong with the tests, and it's because of the redirection code that lives in |
677a5ce to
65c1409
Compare
|
Ok, instead of storing an @bors-servo try |
|
⌛ Trying commit 65c1409 with merge dc3171dde971e2c160f211010dcc82af930c1be3... |
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
| match header_names { | ||
| // Subsubstep 2. | ||
| Some(list) if request.credentials_mode != CredentialsMode::Include => { | ||
| if list.iter().any(|s| **s == "*".to_owned()) { |
There was a problem hiding this comment.
We should be checking if list.len() == 1 and the first element is "*".
| } | ||
|
|
||
| pub fn is_simple_method(m: &Method) -> bool { | ||
| // https://fetch.spec.whatwg.org/#cors-safelisted-method |
| // Step 7 | ||
| let same_origin = location_url.origin()== request.current_url().origin(); | ||
| // FIXME: Correctly use request's origin | ||
| let same_origin = location_url.origin() == request.current_url().origin(); |
There was a problem hiding this comment.
Let's use the correct origin here. We can create an ImmutableOrigin value from the url's origin and compare them.
There was a problem hiding this comment.
That shouldn't be neccessary either. All code paths that come from RequestInit should already have an ImmutableOrigin set for them.
| // Step 11 | ||
| if response.actual_response().status.map_or(false, |code| | ||
| ((code == StatusCode::MovedPermanently || code == StatusCode::Found) && request.method == Method::Post) || | ||
| code == StatusCode::SeeOther) { |
There was a problem hiding this comment.
I don't think that this change is an improvement. I found it easier to read the code before.
There was a problem hiding this comment.
The improvement here is that the code doesn't panic when it encounters a None on the status field of the actual response.
| // TODO: Prompt the user for proxy authentication credentials | ||
| // Wrong, but will have to do until we are able to prompt the user | ||
| // otherwise this creates an infinite loop | ||
| // We basically pretend that the user declined to enter credentials |
There was a problem hiding this comment.
This comment is incorrect if we don't return response like the old code did.
| preflight.initiator = request.initiator.clone(); | ||
| preflight.type_ = request.type_.clone(); | ||
| preflight.destination = request.destination.clone(); | ||
| preflight.origin = request.origin.clone(); |
| // Substep 4 | ||
| // Substep 5 | ||
| if (methods.iter().any(|m| m.as_ref() == "*") || | ||
| header_names.iter().any(|hn| **hn == "*".to_owned())) && |
| // Substep 6 | ||
| // Substep 8 | ||
| if request.headers.iter().any( | ||
| |header| header.name().to_ascii_lowercase() == "authorization" && |
There was a problem hiding this comment.
No need for lowercasing; UniCase ignores string case when comparing.
| // Substep 8 | ||
| if request.headers.iter().any( | ||
| |header| header.name().to_ascii_lowercase() == "authorization" && | ||
| header_names.iter().all(|hn| *hn != UniCase(header.name().to_owned()))) { |
There was a problem hiding this comment.
Can we do UniCase(header.name()) instead?
|
This can r=me with the WIP commit merged into the original related change. |
|
@bors-servo r=jdm |
|
📌 Commit 268f78e has been approved by |
Update fetch methods Includes updates to main fetch, scheme fetch, HTTP fetch, HTTP-redirect fetch, HTTP-network fetch, HTTP-network-or-cache fetch and CORS preflight fetch. <!-- 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/17521) <!-- Reviewable:end -->
|
💔 Test failed - mac-rel-wpt3 |
|
@bors-servo retry
|
Update fetch methods Includes updates to main fetch, scheme fetch, HTTP fetch, HTTP-redirect fetch, HTTP-network fetch, HTTP-network-or-cache fetch and CORS preflight fetch. <!-- 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/17521) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Includes updates to main fetch, scheme fetch, HTTP fetch, HTTP-redirect fetch, HTTP-network fetch, HTTP-network-or-cache fetch and CORS preflight fetch.
This change is