mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Fix clippy warnings in components/shared/net/request.rs (#31551)
* Fix clippy warnings in components/shared/net/request.rs Signed-off-by: mateoferon <mateo.feron@elipce.com> * fixup! Fix clippy warnings in components/shared/net/request.rs --------- Signed-off-by: mateoferon <mateo.feron@elipce.com>
This commit is contained in:
parent
52c4f57085
commit
0748579803
1 changed files with 32 additions and 35 deletions
|
@ -208,7 +208,7 @@ impl RequestBody {
|
|||
}
|
||||
|
||||
pub fn len(&self) -> Option<usize> {
|
||||
self.total_bytes.clone()
|
||||
self.total_bytes
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,19 +567,19 @@ impl Request {
|
|||
|
||||
/// <https://fetch.spec.whatwg.org/#subresource-request>
|
||||
pub fn is_subresource_request(&self) -> bool {
|
||||
match self.destination {
|
||||
matches!(
|
||||
self.destination,
|
||||
Destination::Audio |
|
||||
Destination::Font |
|
||||
Destination::Image |
|
||||
Destination::Manifest |
|
||||
Destination::Script |
|
||||
Destination::Style |
|
||||
Destination::Track |
|
||||
Destination::Video |
|
||||
Destination::Xslt |
|
||||
Destination::None => true,
|
||||
_ => false,
|
||||
}
|
||||
Destination::Font |
|
||||
Destination::Image |
|
||||
Destination::Manifest |
|
||||
Destination::Script |
|
||||
Destination::Style |
|
||||
Destination::Track |
|
||||
Destination::Video |
|
||||
Destination::Xslt |
|
||||
Destination::None
|
||||
)
|
||||
}
|
||||
|
||||
pub fn timing_type(&self) -> ResourceTimingType {
|
||||
|
@ -605,7 +605,7 @@ impl Referrer {
|
|||
// TODO: values in the control-code range are being quietly stripped out by
|
||||
// HeaderMap and never reach this function to be loudly rejected!
|
||||
fn is_cors_unsafe_request_header_byte(value: &u8) -> bool {
|
||||
match value {
|
||||
matches!(value,
|
||||
0x00..=0x08 |
|
||||
0x10..=0x19 |
|
||||
0x22 |
|
||||
|
@ -621,9 +621,8 @@ fn is_cors_unsafe_request_header_byte(value: &u8) -> bool {
|
|||
0x5D |
|
||||
0x7B |
|
||||
0x7D |
|
||||
0x7F => true,
|
||||
_ => false,
|
||||
}
|
||||
0x7F
|
||||
)
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#cors-safelisted-request-header
|
||||
|
@ -635,18 +634,19 @@ fn is_cors_safelisted_request_accept(value: &[u8]) -> bool {
|
|||
// https://fetch.spec.whatwg.org/#cors-safelisted-request-header
|
||||
// subclauses `accept-language`, `content-language`
|
||||
fn is_cors_safelisted_language(value: &[u8]) -> bool {
|
||||
value.iter().all(|&x| match x {
|
||||
0x30..=0x39 |
|
||||
0x41..=0x5A |
|
||||
0x61..=0x7A |
|
||||
0x20 |
|
||||
0x2A |
|
||||
0x2C |
|
||||
0x2D |
|
||||
0x2E |
|
||||
0x3B |
|
||||
0x3D => true,
|
||||
_ => false,
|
||||
value.iter().all(|&x| {
|
||||
matches!(x,
|
||||
0x30..=0x39 |
|
||||
0x41..=0x5A |
|
||||
0x61..=0x7A |
|
||||
0x20 |
|
||||
0x2A |
|
||||
0x2C |
|
||||
0x2D |
|
||||
0x2E |
|
||||
0x3B |
|
||||
0x3D
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -697,10 +697,7 @@ pub fn is_cors_safelisted_request_header<N: AsRef<str>, V: AsRef<[u8]>>(
|
|||
|
||||
/// <https://fetch.spec.whatwg.org/#cors-safelisted-method>
|
||||
pub fn is_cors_safelisted_method(m: &Method) -> bool {
|
||||
match *m {
|
||||
Method::GET | Method::HEAD | Method::POST => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*m, Method::GET | Method::HEAD | Method::POST)
|
||||
}
|
||||
|
||||
/// <https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name>
|
||||
|
@ -733,7 +730,7 @@ pub fn get_cors_unsafe_header_names(headers: &HeaderMap) -> Vec<HeaderName> {
|
|||
}
|
||||
|
||||
// Step 6
|
||||
return convert_header_names_to_sorted_lowercase_set(unsafe_names);
|
||||
convert_header_names_to_sorted_lowercase_set(unsafe_names)
|
||||
}
|
||||
|
||||
/// <https://fetch.spec.whatwg.org/#ref-for-convert-header-names-to-a-sorted-lowercase-set>
|
||||
|
@ -745,5 +742,5 @@ pub fn convert_header_names_to_sorted_lowercase_set(
|
|||
let mut ordered_set = header_names.to_vec();
|
||||
ordered_set.sort_by(|a, b| a.as_str().partial_cmp(b.as_str()).unwrap());
|
||||
ordered_set.dedup();
|
||||
return ordered_set.into_iter().cloned().collect();
|
||||
ordered_set.into_iter().cloned().collect()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue