From 028970cdf0ee7fbfe2c80bd4b34994818285efb3 Mon Sep 17 00:00:00 2001 From: _ <> Date: Sun, 29 Nov 2020 21:55:24 +0000 Subject: [PATCH] :recycle: Remove the hyper dep from ptth_server.exe --- crates/ptth_file_server_bin/Cargo.toml | 20 -------------------- crates/ptth_file_server_bin/src/main.rs | 3 +-- crates/ptth_server/Cargo.toml | 1 - crates/ptth_server/src/errors.rs | 8 ++++---- crates/ptth_server/src/file_server/errors.rs | 2 +- crates/ptth_server/src/file_server/mod.rs | 6 +++--- crates/ptth_server/src/file_server/tests.rs | 4 +--- crates/ptth_server/src/lib.rs | 2 +- 8 files changed, 11 insertions(+), 35 deletions(-) diff --git a/crates/ptth_file_server_bin/Cargo.toml b/crates/ptth_file_server_bin/Cargo.toml index 4061612..bf2fc2d 100644 --- a/crates/ptth_file_server_bin/Cargo.toml +++ b/crates/ptth_file_server_bin/Cargo.toml @@ -8,34 +8,14 @@ license = "AGPL-3.0" [dependencies] -aho-corasick = "0.7.14" anyhow = "1.0.34" -base64 = "0.12.3" -blake3 = "0.3.7" -futures = "0.3.7" handlebars = "3.5.1" http = "0.2.1" hyper = "0.13.8" -lazy_static = "1.4.0" -percent-encoding = "2.1.0" -pulldown-cmark = "0.8.0" -regex = "1.4.1" -reqwest = { version = "0.10.8", features = ["stream"] } -rmp-serde = "0.14.4" serde = {version = "1.0.117", features = ["derive"]} structopt = "0.3.20" -thiserror = "1.0.22" tokio = { version = "0.2.22", features = ["full"] } -tracing = "0.1.21" -tracing-futures = "0.2.4" tracing-subscriber = "0.2.15" -toml = "0.5.7" -always_equal = { path = "../always_equal" } ptth_core = { path = "../ptth_core" } ptth_server = { path = "../ptth_server" } - -[dev-dependencies] - -maplit = "1.0.2" -rand = "0.6.5" diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index 11482a0..cec4bb2 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -24,7 +24,6 @@ use ptth_core::{ prelude::*, }; use ptth_server::{ - errors::ServerError, file_server, load_toml, }; @@ -42,7 +41,7 @@ struct ServerState <'a> { } async fn handle_all (req: Request , state: Arc >) --> Result , ServerError> +-> Result , anyhow::Error> { use std::str::FromStr; diff --git a/crates/ptth_server/Cargo.toml b/crates/ptth_server/Cargo.toml index bb8ed1b..0095a55 100644 --- a/crates/ptth_server/Cargo.toml +++ b/crates/ptth_server/Cargo.toml @@ -15,7 +15,6 @@ blake3 = "0.3.7" futures = "0.3.7" handlebars = "3.5.1" http = "0.2.1" -hyper = "0.13.8" lazy_static = "1.4.0" percent-encoding = "2.1.0" pulldown-cmark = "0.8.0" diff --git a/crates/ptth_server/src/errors.rs b/crates/ptth_server/src/errors.rs index a2bb0c9..4ebdbe1 100644 --- a/crates/ptth_server/src/errors.rs +++ b/crates/ptth_server/src/errors.rs @@ -32,13 +32,13 @@ pub enum ServerError { // Hyper stuff #[error ("Hyper HTTP error")] - Http (#[from] hyper::http::Error), + Http (#[from] http::Error), - #[error ("Hyper invalid header name")] - InvalidHeaderName (#[from] hyper::header::InvalidHeaderName), + //#[error ("Hyper invalid header name")] + //InvalidHeaderName (#[from] hyper::header::InvalidHeaderName), #[error ("API key invalid")] - ApiKeyInvalid (hyper::header::InvalidHeaderValue), + ApiKeyInvalid (http::header::InvalidHeaderValue), // MessagePack stuff diff --git a/crates/ptth_server/src/file_server/errors.rs b/crates/ptth_server/src/file_server/errors.rs index e5b7cc5..9845340 100644 --- a/crates/ptth_server/src/file_server/errors.rs +++ b/crates/ptth_server/src/file_server/errors.rs @@ -33,5 +33,5 @@ pub enum FileServerError { Markdown (#[from] MarkdownError), #[error ("Invalid URI")] - InvalidUri (#[from] hyper::http::uri::InvalidUri), + InvalidUri (#[from] http::uri::InvalidUri), } diff --git a/crates/ptth_server/src/file_server/mod.rs b/crates/ptth_server/src/file_server/mod.rs index 7ef6b66..f205515 100644 --- a/crates/ptth_server/src/file_server/mod.rs +++ b/crates/ptth_server/src/file_server/mod.rs @@ -468,7 +468,7 @@ fn internal_serve_dir ( path: &Path, dir: tokio::fs::ReadDir, full_path: PathBuf, - uri: &hyper::Uri + uri: &http::Uri ) -> Result { @@ -494,7 +494,7 @@ fn internal_serve_dir ( async fn internal_serve_file ( mut file: tokio::fs::File, - uri: &hyper::Uri, + uri: &http::Uri, send_body: bool, headers: &HashMap > ) @@ -571,7 +571,7 @@ async fn internal_serve_all ( info! ("Client requested {}", uri); - let uri = hyper::Uri::from_str (uri).map_err (FileServerError::InvalidUri)?; + let uri = http::Uri::from_str (uri).map_err (FileServerError::InvalidUri)?; let send_body = match &method { Method::Get => true, diff --git a/crates/ptth_server/src/file_server/tests.rs b/crates/ptth_server/src/file_server/tests.rs index cbb527f..aa1a541 100644 --- a/crates/ptth_server/src/file_server/tests.rs +++ b/crates/ptth_server/src/file_server/tests.rs @@ -210,9 +210,7 @@ fn file_server () { #[test] fn parse_uri () { - use hyper::Uri; - - assert! (Uri::from_maybe_shared ("/").is_ok ()); + assert! (http::Uri::from_maybe_shared ("/").is_ok ()); } #[test] diff --git a/crates/ptth_server/src/lib.rs b/crates/ptth_server/src/lib.rs index 203af47..ce63528 100644 --- a/crates/ptth_server/src/lib.rs +++ b/crates/ptth_server/src/lib.rs @@ -15,7 +15,7 @@ use std::{ use futures::FutureExt; use handlebars::Handlebars; -use hyper::{ +use http::status::{ StatusCode, }; use reqwest::Client;