diff --git a/Cargo.toml b/Cargo.toml index 598b6313..0440d6f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ path-tree = "0.7" # http # TODO: wait headers-v1.0 -headers = { git = "https://github.com/hyperium/headers.git", rev = "4400aa9" } +headers = "0.4" http = "1" http-body = "1" http-body-util = "0.1" diff --git a/viz-core/src/middleware/cors.rs b/viz-core/src/middleware/cors.rs index 3ca29479..2790330a 100644 --- a/viz-core/src/middleware/cors.rs +++ b/viz-core/src/middleware/cors.rs @@ -208,9 +208,8 @@ where type Output = Result; async fn call(&self, req: Request) -> Self::Output { - let origin = match req.header(ORIGIN).filter(is_not_empty) { - Some(origin) => origin, - None => return self.h.call(req).await.map(IntoResponse::into_response), + let Some(origin) = req.header(ORIGIN).filter(is_not_empty) else { + return self.h.call(req).await.map(IntoResponse::into_response); }; if !self.config.allow_origins.contains(&origin) diff --git a/viz-core/src/types/websocket.rs b/viz-core/src/types/websocket.rs index f72d6d7c..8169b086 100644 --- a/viz-core/src/types/websocket.rs +++ b/viz-core/src/types/websocket.rs @@ -76,9 +76,8 @@ impl WebSocket { let on_upgrade = self.on_upgrade.take().expect("missing OnUpgrade"); tokio::task::spawn(async move { - let upgraded = match on_upgrade.await { - Ok(upgraded) => upgraded, - Err(_) => return, + let Ok(upgraded) = on_upgrade.await else { + return; }; let socket = diff --git a/viz-handlers/src/serve.rs b/viz-handlers/src/serve.rs index 887d2286..09280c90 100644 --- a/viz-handlers/src/serve.rs +++ b/viz-handlers/src/serve.rs @@ -196,9 +196,10 @@ fn serve(path: &Path, headers: &HeaderMap) -> Result { last_modified.replace(LastModified::from(modified)); } + // See https://github.com/hyperium/headers/pull/155 if let Some((start, end)) = headers .typed_get::() - .and_then(|range| range.iter().next()) + .and_then(|range| range.satisfiable_ranges(100).next()) { let start = match start { Bound::Included(n) => n,