Skip to content
Snippets Groups Projects
Unverified Commit 9514f99c authored by Linfeng Qian's avatar Linfeng Qian
Browse files

cargo update and fix clippy

parent 9b3871c1
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
1.61.0 stable
...@@ -842,8 +842,8 @@ impl MainHandler { ...@@ -842,8 +842,8 @@ impl MainHandler {
resp.headers.set(headers::ContentType::html()); resp.headers.set(headers::ContentType::html());
if self.compress.is_some() { if self.compress.is_some() {
if let Some(&AcceptEncoding(ref encodings)) = req.headers.get::<AcceptEncoding>() { if let Some(AcceptEncoding(encodings)) = req.headers.get::<AcceptEncoding>() {
for &QualityItem { ref item, .. } in encodings { for QualityItem { item, .. } in encodings {
if *item == Encoding::Deflate || *item == Encoding::Gzip { if *item == Encoding::Deflate || *item == Encoding::Gzip {
resp.headers.set(ContentEncoding(vec![item.clone()])); resp.headers.set(ContentEncoding(vec![item.clone()]));
} }
...@@ -914,7 +914,7 @@ impl MainHandler { ...@@ -914,7 +914,7 @@ impl MainHandler {
if range.is_some() { if range.is_some() {
// [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match // [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match
// Check header::If-Match // Check header::If-Match
if let Some(&IfMatch::Items(ref items)) = req.headers.get::<IfMatch>() { if let Some(IfMatch::Items(items)) = req.headers.get::<IfMatch>() {
if !items.iter().any(|item| item.strong_eq(&etag)) { if !items.iter().any(|item| item.strong_eq(&etag)) {
return Err(IronError::new( return Err(IronError::new(
StringError("Etag not matched".to_owned()), StringError("Etag not matched".to_owned()),
...@@ -926,8 +926,8 @@ impl MainHandler { ...@@ -926,8 +926,8 @@ impl MainHandler {
// [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range // [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range
let matched_ifrange = match req.headers.get::<IfRange>() { let matched_ifrange = match req.headers.get::<IfRange>() {
Some(&IfRange::EntityTag(ref etag_ifrange)) => etag.weak_eq(etag_ifrange), Some(IfRange::EntityTag(etag_ifrange)) => etag.weak_eq(etag_ifrange),
Some(&IfRange::Date(HttpDate(ref date_ifrange))) => { Some(IfRange::Date(HttpDate(date_ifrange))) => {
time::at(modified) <= *date_ifrange time::at(modified) <= *date_ifrange
} }
None => true, None => true,
...@@ -937,7 +937,7 @@ impl MainHandler { ...@@ -937,7 +937,7 @@ impl MainHandler {
} }
match range { match range {
Some(&Range::Bytes(ref ranges)) => { Some(Range::Bytes(ranges)) => {
if let Some(range) = ranges.get(0) { if let Some(range) = ranges.get(0) {
let (offset, length) = match *range { let (offset, length) = match *range {
ByteRangeSpec::FromTo(x, mut y) => { ByteRangeSpec::FromTo(x, mut y) => {
...@@ -1022,8 +1022,8 @@ impl MainHandler { ...@@ -1022,8 +1022,8 @@ impl MainHandler {
if resp.status != Some(status::PartialContent) if resp.status != Some(status::PartialContent)
&& exts.iter().any(|ext| path_str.ends_with(ext)) && exts.iter().any(|ext| path_str.ends_with(ext))
{ {
if let Some(&AcceptEncoding(ref encodings)) = req.headers.get::<AcceptEncoding>() { if let Some(AcceptEncoding(encodings)) = req.headers.get::<AcceptEncoding>() {
for &QualityItem { ref item, .. } in encodings { for QualityItem { item, .. } in encodings {
if *item == Encoding::Deflate || *item == Encoding::Gzip { if *item == Encoding::Deflate || *item == Encoding::Gzip {
resp.headers.set(ContentEncoding(vec![item.clone()])); resp.headers.set(ContentEncoding(vec![item.clone()]));
break; break;
......
...@@ -40,14 +40,14 @@ impl AfterMiddleware for CompressionHandler { ...@@ -40,14 +40,14 @@ impl AfterMiddleware for CompressionHandler {
} }
let mut encoding: Option<Encoding> = None; let mut encoding: Option<Encoding> = None;
if let Some(&ContentEncoding(ref objs)) = resp.headers.get::<ContentEncoding>() { if let Some(ContentEncoding(objs)) = resp.headers.get::<ContentEncoding>() {
encoding = objs encoding = objs
.iter() .iter()
.find(|obj| *obj == &Encoding::Deflate || *obj == &Encoding::Gzip) .find(|obj| *obj == &Encoding::Deflate || *obj == &Encoding::Gzip)
.cloned(); .cloned();
} }
if encoding.is_none() { if encoding.is_none() {
if let Some(&TransferEncoding(ref objs)) = resp.headers.get::<TransferEncoding>() { if let Some(TransferEncoding(objs)) = resp.headers.get::<TransferEncoding>() {
encoding = objs encoding = objs
.iter() .iter()
.find(|obj| *obj == &Encoding::Deflate || *obj == &Encoding::Gzip) .find(|obj| *obj == &Encoding::Deflate || *obj == &Encoding::Gzip)
......
...@@ -42,7 +42,7 @@ impl Deref for StringError { ...@@ -42,7 +42,7 @@ impl Deref for StringError {
type Target = str; type Target = str;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&*self.0 &self.0
} }
} }
...@@ -133,7 +133,7 @@ pub fn system_time_to_date_time(t: SystemTime) -> DateTime<Local> { ...@@ -133,7 +133,7 @@ pub fn system_time_to_date_time(t: SystemTime) -> DateTime<Local> {
} }
} }
}; };
Local.timestamp(sec, nsec) Local.timestamp_opt(sec, nsec).unwrap()
} }
pub fn error_resp(s: status::Status, msg: &str) -> Response { pub fn error_resp(s: status::Status, msg: &str) -> Response {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment