forked from Deuxfleurs/tricot
cargo clippy
This commit is contained in:
parent
e0912dc5fe
commit
f7a5b29b71
3 changed files with 9 additions and 5 deletions
10
src/https.rs
10
src/https.rs
|
@ -116,7 +116,7 @@ async fn handle(
|
||||||
.to_str()?
|
.to_str()?
|
||||||
};
|
};
|
||||||
let path = req.uri().path();
|
let path = req.uri().path();
|
||||||
let accept_encoding = accept_encoding_fork::encodings(req.headers()).unwrap_or(vec![]);
|
let accept_encoding = accept_encoding_fork::encodings(req.headers()).unwrap_or_else(|_| vec![]);
|
||||||
|
|
||||||
let best_match = proxy_config
|
let best_match = proxy_config
|
||||||
.entries
|
.entries
|
||||||
|
@ -194,6 +194,7 @@ async fn try_compress(
|
||||||
Encoding::Deflate,
|
Encoding::Deflate,
|
||||||
Encoding::Gzip,
|
Encoding::Gzip,
|
||||||
];
|
];
|
||||||
|
#[allow(clippy::float_cmp)]
|
||||||
let encoding_opt = accept_encoding
|
let encoding_opt = accept_encoding
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, q)| *q == max_q)
|
.filter(|(_, q)| *q == max_q)
|
||||||
|
@ -250,13 +251,16 @@ async fn try_compress(
|
||||||
}
|
}
|
||||||
|
|
||||||
// put beginning chunks back into body
|
// put beginning chunks back into body
|
||||||
let body = futures::stream::iter(chunks.into_iter().map(|c| Ok(c))).chain(body);
|
let body = futures::stream::iter(chunks.into_iter().map(Ok)).chain(body);
|
||||||
|
|
||||||
// make an async reader from that for compressor
|
// make an async reader from that for compressor
|
||||||
let body_rd =
|
let body_rd =
|
||||||
StreamReader::new(body.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)));
|
StreamReader::new(body.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)));
|
||||||
|
|
||||||
debug!("Compressing response body as {:?} (at least {} bytes)", encoding, sum_lengths);
|
debug!(
|
||||||
|
"Compressing response body as {:?} (at least {} bytes)",
|
||||||
|
encoding, sum_lengths
|
||||||
|
);
|
||||||
head.headers.remove(header::CONTENT_LENGTH);
|
head.headers.remove(header::CONTENT_LENGTH);
|
||||||
|
|
||||||
let compressed_body = match encoding {
|
let compressed_body = match encoding {
|
||||||
|
|
|
@ -105,7 +105,7 @@ async fn main() {
|
||||||
enable_compression: opt.enable_compression,
|
enable_compression: opt.enable_compression,
|
||||||
compress_mime_types: opt
|
compress_mime_types: opt
|
||||||
.compress_mime_types
|
.compress_mime_types
|
||||||
.split(",")
|
.split(',')
|
||||||
.map(|x| x.to_string())
|
.map(|x| x.to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn is_hop_header(name: &HeaderName) -> bool {
|
||||||
fn remove_hop_headers(headers: &HeaderMap<HeaderValue>) -> HeaderMap<HeaderValue> {
|
fn remove_hop_headers(headers: &HeaderMap<HeaderValue>) -> HeaderMap<HeaderValue> {
|
||||||
let mut result = HeaderMap::new();
|
let mut result = HeaderMap::new();
|
||||||
for (k, v) in headers.iter() {
|
for (k, v) in headers.iter() {
|
||||||
if !is_hop_header(&k) {
|
if !is_hop_header(k) {
|
||||||
result.append(k.clone(), v.clone());
|
result.append(k.clone(), v.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue