Skip to content

Commit

Permalink
Auto merge of #29637 - AnthonyJ3:Use-same-origin-as-default-credentia…
Browse files Browse the repository at this point in the history
…l-mode-for-RequestInit-fix, r=<try>

Use same-origin as default credential mode for RequestInit fix

<!-- Please describe your changes on the following line: -->
- Updated the default credential mode from omit to same-origin as per: whatwg/fetch#1153
- Deleted instances of fallback credentials
---

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #29633  (GitHub issue number if applicable)
- [X] There are tests for these changes
  • Loading branch information
bors-servo committed Apr 20, 2023
2 parents 9acb9cc + 7fda52b commit f2b8366
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/net_traits/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl RequestBuilder {
mode: RequestMode::NoCors,
cache_mode: CacheMode::Default,
use_cors_preflight: false,
credentials_mode: CredentialsMode::Omit,
credentials_mode: CredentialsMode::CredentialsSameOrigin,
use_url_credentials: false,
origin: ImmutableOrigin::new_opaque(),
referrer: referrer,
Expand Down
13 changes: 1 addition & 12 deletions components/script/dom/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ impl Request {
// Step 2
let mut fallback_mode: Option<NetTraitsRequestMode> = None;

// FIXME(cybai): As the spec changed in https://github.com/whatwg/fetch/pull/1153,
// we will need to change the default value of credentials for
// NetTraitsRequest and then remove fallback here.
let mut fallback_credentials: Option<NetTraitsRequestCredentials> = None;

// Step 3
let base_url = global.api_base_url();

Expand All @@ -107,8 +102,6 @@ impl Request {
temporary_request = net_request_from_global(global, url);
// Step 5.5
fallback_mode = Some(NetTraitsRequestMode::CorsMode);
// FIXME(cybai): remove this line when we can remove the fallback of credentials
fallback_credentials = Some(NetTraitsRequestCredentials::CredentialsSameOrigin);
},
// Step 6
RequestInfo::Request(ref input_request) => {
Expand Down Expand Up @@ -239,11 +232,7 @@ impl Request {
}

// Step 19
let credentials = init
.credentials
.as_ref()
.map(|m| m.clone().into())
.or(fallback_credentials);
let credentials = init.credentials.as_ref().map(|m| m.clone().into());

if let Some(c) = credentials {
request.credentials_mode = c;
Expand Down

0 comments on commit f2b8366

Please sign in to comment.