clippy: fix warnings in components/net (#31564)

* clippy: fix some warnings in components/net

* fix: review comments

* fix: tidy
This commit is contained in:
eri 2024-03-10 16:34:16 +01:00 committed by GitHub
parent 099bb0fa19
commit 67b277c992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 325 additions and 379 deletions

View file

@ -84,7 +84,7 @@ pub struct CancellationListener {
impl CancellationListener {
pub fn new(cancel_chan: Option<IpcReceiver<()>>) -> Self {
Self {
cancel_chan: cancel_chan,
cancel_chan,
cancelled: false,
}
}
@ -121,7 +121,7 @@ pub async fn fetch(request: &mut Request, target: Target<'_>, context: &FetchCon
.unwrap()
.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
fetch_with_cors_cache(request, &mut CorsCache::new(), target, context).await;
fetch_with_cors_cache(request, &mut CorsCache::default(), target, context).await;
}
pub async fn fetch_with_cors_cache(
@ -161,7 +161,7 @@ pub async fn fetch_with_cors_cache(
}
// Step 8.
main_fetch(request, cache, false, false, target, &mut None, &context).await;
main_fetch(request, cache, false, false, target, &mut None, context).await;
}
/// <https://www.w3.org/TR/CSP/#should-block-request>
@ -209,15 +209,15 @@ pub async fn main_fetch(
}
// Step 2.
if request.local_urls_only {
if !matches!(
if request.local_urls_only &&
!matches!(
request.current_url().scheme(),
"about" | "blob" | "data" | "filesystem"
) {
response = Some(Response::network_error(NetworkError::Internal(
"Non-local scheme".into(),
)));
}
)
{
response = Some(Response::network_error(NetworkError::Internal(
"Non-local scheme".into(),
)));
}
// Step 2.2.
@ -267,7 +267,7 @@ pub async fn main_fetch(
)
},
};
request.referrer = referrer_url.map_or(Referrer::NoReferrer, |url| Referrer::ReferrerUrl(url));
request.referrer = referrer_url.map_or(Referrer::NoReferrer, Referrer::ReferrerUrl);
// Step 9.
// TODO: handle FTP URLs.
@ -451,7 +451,7 @@ pub async fn main_fetch(
*body = ResponseBody::Empty;
}
internal_response.get_network_error().map(|e| e.clone())
internal_response.get_network_error().cloned()
};
// Execute deferred rebinding of response.
@ -469,7 +469,7 @@ pub async fn main_fetch(
response_loaded = true;
// Step 19.2.
let ref integrity_metadata = &request.integrity_metadata;
let integrity_metadata = &request.integrity_metadata;
if response.termination_reason.is_none() &&
!is_response_integrity_valid(integrity_metadata, &response)
{
@ -502,8 +502,8 @@ pub async fn main_fetch(
// in http_network_fetch. However, we can't yet follow the request
// upload progress, so I'm keeping it here for now and pretending
// the body got sent in one chunk
target.process_request_body(&request);
target.process_request_eof(&request);
target.process_request_body(request);
target.process_request_eof(request);
}
// Step 22.
@ -518,7 +518,7 @@ pub async fn main_fetch(
target.process_response_eof(&response);
if let Ok(http_cache) = context.state.http_cache.write() {
http_cache.update_awaiting_consumers(&request, &response);
http_cache.update_awaiting_consumers(request, &response);
}
// Steps 25-27.