From 64f2b8f14fac78118d859c1b96a085c778d5b568 Mon Sep 17 00:00:00 2001 From: Devashish Dixit Date: Mon, 3 Feb 2025 08:40:56 +0800 Subject: [PATCH] Update dependencies (#64) --- Cargo.toml | 26 +++++++++++------------ src/call.rs | 12 ++++++----- src/options/mod.rs | 16 +++++++------- test-suite/gzip/client/Cargo.toml | 2 +- test-suite/gzip/client/build.rs | 2 +- test-suite/gzip/server/Cargo.toml | 18 +++++++--------- test-suite/gzip/server/build.rs | 2 +- test-suite/simple/client/Cargo.toml | 2 +- test-suite/simple/client/build.rs | 2 +- test-suite/simple/server/Cargo.toml | 18 +++++++--------- test-suite/simple/server/build.rs | 2 +- test-suite/simple/server/src/main.rs | 31 ++++++++++++---------------- 12 files changed, 63 insertions(+), 70 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4775626..e474e12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,23 +12,23 @@ keywords = ["grpc", "grpc-web", "tonic", "wasm"] edition = "2021" [dependencies] -base64 = "0.22.0" -byteorder = "1.5.0" -bytes = "1.5.0" -futures-util = { version = "0.3.30", default-features = false } +base64 = "0.22" +byteorder = "1" +bytes = "1" +futures-util = { version = "0.3", default-features = false } http = "1" http-body = "1" http-body-util = "0.1" -httparse = "1.8.0" -js-sys = "0.3.69" -pin-project = "1.1.5" -thiserror = "1.0.57" +httparse = "1" +js-sys = "0.3" +pin-project = "1" +thiserror = "1" tonic = { version = "0.12", default-features = false } -tower-service = "0.3.2" -wasm-bindgen = "0.2.92" -wasm-bindgen-futures = "0.4.42" -wasm-streams = "0.4.0" -web-sys = { version = "0.3.69", features = [ +tower-service = "0.3" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4" +wasm-streams = "0.4" +web-sys = { version = "0.3", features = [ "Headers", "ReadableStream", "ReferrerPolicy", diff --git a/src/call.rs b/src/call.rs index b23b618..de7c502 100644 --- a/src/call.rs +++ b/src/call.rs @@ -67,12 +67,14 @@ fn prepare_request( headers: Headers, body: Option, ) -> Result { - let mut init = RequestInit::new(); + let init = RequestInit::new(); - init.method("POST") - .headers(headers.as_ref()) - .body(body.as_ref()) - .credentials(RequestCredentials::SameOrigin); + init.set_method("POST"); + init.set_headers(headers.as_ref()); + if let Some(ref body) = body { + init.set_body(body); + } + init.set_credentials(RequestCredentials::SameOrigin); web_sys::Request::new_with_str_and_init(url, &init).map_err(Error::js_error) } diff --git a/src/options/mod.rs b/src/options/mod.rs index f98979f..94f0529 100644 --- a/src/options/mod.rs +++ b/src/options/mod.rs @@ -82,34 +82,34 @@ impl FetchOptions { impl From for RequestInit { fn from(value: FetchOptions) -> Self { - let mut init = RequestInit::new(); + let init = RequestInit::new(); if let Some(cache) = value.cache { - init.cache(cache.into()); + init.set_cache(cache.into()); } if let Some(credentials) = value.credentials { - init.credentials(credentials.into()); + init.set_credentials(credentials.into()); } if let Some(ref integrity) = value.integrity { - init.integrity(integrity); + init.set_integrity(integrity); } if let Some(mode) = value.mode { - init.mode(mode.into()); + init.set_mode(mode.into()); } if let Some(redirect) = value.redirect { - init.redirect(redirect.into()); + init.set_redirect(redirect.into()); } if let Some(ref referrer) = value.referrer { - init.referrer(referrer); + init.set_referrer(referrer); } if let Some(referrer_policy) = value.referrer_policy { - init.referrer_policy(referrer_policy.into()); + init.set_referrer_policy(referrer_policy.into()); } init diff --git a/test-suite/gzip/client/Cargo.toml b/test-suite/gzip/client/Cargo.toml index 7e5b45d..407b5b1 100644 --- a/test-suite/gzip/client/Cargo.toml +++ b/test-suite/gzip/client/Cargo.toml @@ -20,4 +20,4 @@ tonic-build = { version = "0.12", default-features = false, features = [ [dev-dependencies] tonic-web-wasm-client = { path = "../../.." } -wasm-bindgen-test = "0.3.42" +wasm-bindgen-test = "0.3" diff --git a/test-suite/gzip/client/build.rs b/test-suite/gzip/client/build.rs index a655670..ca91c37 100644 --- a/test-suite/gzip/client/build.rs +++ b/test-suite/gzip/client/build.rs @@ -4,5 +4,5 @@ fn main() -> io::Result<()> { tonic_build::configure() .build_server(false) .build_client(true) - .compile(&["echo.proto"], &["../proto"]) + .compile_protos(&["echo.proto"], &["../proto"]) } diff --git a/test-suite/gzip/server/Cargo.toml b/test-suite/gzip/server/Cargo.toml index 4033814..2ec400f 100644 --- a/test-suite/gzip/server/Cargo.toml +++ b/test-suite/gzip/server/Cargo.toml @@ -6,15 +6,13 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -futures-core = "0.3.30" -http = "0.2.11" -prost = "0.12.3" -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } -tonic = { version = "0.11.0", features = ["gzip"] } -tonic-web = "0.11.0" -tower-http = { version = "0.4.4", default-features = false, features = [ - "cors", -] } +futures-core = "0.3" +http = "1" +prost = "0.13" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +tonic = { version = "0.12", features = ["gzip"] } +tonic-web = "0.12" +tower-http = { version = "0.6", default-features = false, features = ["cors"] } [build-dependencies] -tonic-build = "0.11.0" +tonic-build = "0.12" diff --git a/test-suite/gzip/server/build.rs b/test-suite/gzip/server/build.rs index 885e47e..f0898a2 100644 --- a/test-suite/gzip/server/build.rs +++ b/test-suite/gzip/server/build.rs @@ -4,5 +4,5 @@ fn main() -> io::Result<()> { tonic_build::configure() .build_server(true) .build_client(false) - .compile(&["echo.proto"], &["../proto"]) + .compile_protos(&["echo.proto"], &["../proto"]) } diff --git a/test-suite/simple/client/Cargo.toml b/test-suite/simple/client/Cargo.toml index aee6e2b..d43f791 100644 --- a/test-suite/simple/client/Cargo.toml +++ b/test-suite/simple/client/Cargo.toml @@ -19,4 +19,4 @@ tonic-build = { version = "0.12", default-features = false, features = [ [dev-dependencies] tonic-web-wasm-client = { path = "../../.." } -wasm-bindgen-test = "0.3.42" +wasm-bindgen-test = "0.3" diff --git a/test-suite/simple/client/build.rs b/test-suite/simple/client/build.rs index a655670..ca91c37 100644 --- a/test-suite/simple/client/build.rs +++ b/test-suite/simple/client/build.rs @@ -4,5 +4,5 @@ fn main() -> io::Result<()> { tonic_build::configure() .build_server(false) .build_client(true) - .compile(&["echo.proto"], &["../proto"]) + .compile_protos(&["echo.proto"], &["../proto"]) } diff --git a/test-suite/simple/server/Cargo.toml b/test-suite/simple/server/Cargo.toml index 094e16c..810e0a2 100644 --- a/test-suite/simple/server/Cargo.toml +++ b/test-suite/simple/server/Cargo.toml @@ -6,15 +6,13 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -futures-core = "0.3.30" -http = "0.2.11" -prost = "0.12.3" -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } -tonic = "0.11.0" -tonic-web = "0.11.0" -tower-http = { version = "0.4.4", default-features = false, features = [ - "cors", -] } +futures-core = "0.3" +http = "1" +prost = "0.13" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +tonic = "0.12" +tonic-web = "0.12" +tower-http = { version = "0.6", default-features = false, features = ["cors"] } [build-dependencies] -tonic-build = "0.11.0" +tonic-build = "0.12" diff --git a/test-suite/simple/server/build.rs b/test-suite/simple/server/build.rs index 885e47e..f0898a2 100644 --- a/test-suite/simple/server/build.rs +++ b/test-suite/simple/server/build.rs @@ -4,5 +4,5 @@ fn main() -> io::Result<()> { tonic_build::configure() .build_server(true) .build_client(false) - .compile(&["echo.proto"], &["../proto"]) + .compile_protos(&["echo.proto"], &["../proto"]) } diff --git a/test-suite/simple/server/src/main.rs b/test-suite/simple/server/src/main.rs index ed08e5e..1102d15 100644 --- a/test-suite/simple/server/src/main.rs +++ b/test-suite/simple/server/src/main.rs @@ -107,10 +107,17 @@ impl Stream for InfiniteMessageStream { } const DEFAULT_MAX_AGE: Duration = Duration::from_secs(24 * 60 * 60); -const DEFAULT_EXPOSED_HEADERS: [&str; 3] = - ["grpc-status", "grpc-message", "grpc-status-details-bin"]; -const DEFAULT_ALLOW_HEADERS: [&str; 4] = - ["x-grpc-web", "content-type", "x-user-agent", "grpc-timeout"]; +const DEFAULT_EXPOSED_HEADERS: [HeaderName; 3] = [ + HeaderName::from_static("grpc-status"), + HeaderName::from_static("grpc-message"), + HeaderName::from_static("grpc-status-details-bin"), +]; +const DEFAULT_ALLOW_HEADERS: [HeaderName; 4] = [ + HeaderName::from_static("x-grpc-web"), + HeaderName::from_static("content-type"), + HeaderName::from_static("x-user-agent"), + HeaderName::from_static("grpc-timeout"), +]; #[tokio::main] async fn main() -> Result<(), Box> { @@ -124,20 +131,8 @@ async fn main() -> Result<(), Box> { .allow_origin(AllowOrigin::mirror_request()) .allow_credentials(true) .max_age(DEFAULT_MAX_AGE) - .expose_headers( - DEFAULT_EXPOSED_HEADERS - .iter() - .cloned() - .map(HeaderName::from_static) - .collect::>(), - ) - .allow_headers( - DEFAULT_ALLOW_HEADERS - .iter() - .cloned() - .map(HeaderName::from_static) - .collect::>(), - ), + .expose_headers(DEFAULT_EXPOSED_HEADERS) + .allow_headers(DEFAULT_ALLOW_HEADERS), ) .layer(GrpcWebLayer::new()) .add_service(echo)