diff --git a/Cargo.lock b/Cargo.lock index 381d1e0..872321c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -372,9 +372,9 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "candid" -version = "0.10.13" +version = "0.10.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a253bab4a9be502c82332b60cbeee6202ad0692834efeec95fae9f29db33d692" +checksum = "8037a01ec09d6c06883a38bad4f47b8d06158ad360b841e0ae5707c9884dfaf6" dependencies = [ "anyhow", "binread", @@ -395,9 +395,9 @@ dependencies = [ [[package]] name = "candid_derive" -version = "0.6.6" +version = "0.10.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3de398570c386726e7a59d9887b68763c481477f9a043fb998a2e09d428df1a9" +checksum = "fb45f4d5eff3805598ee633dd80f8afb306c023249d34b5b7dfdc2080ea1df2e" dependencies = [ "lazy_static", "proc-macro2", @@ -1383,8 +1383,9 @@ dependencies = [ [[package]] name = "ic-agent" -version = "0.42.0" -source = "git+https://github.com/dfinity/agent-rs?rev=f34acedb5539838ffdbd4cf49a0832303977293f#f34acedb5539838ffdbd4cf49a0832303977293f" +version = "0.44.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5337598ec943bab711e0288319761abb5a7a7087ac226b03472441a90f88e0c" dependencies = [ "arc-swap", "async-channel", @@ -1406,7 +1407,7 @@ dependencies = [ "http-body-util", "ic-certification 3.0.3", "ic-ed25519", - "ic-transport-types 0.42.0", + "ic-transport-types 0.44.3", "ic-verify-bls-signature", "k256", "leb128", @@ -1585,9 +1586,9 @@ dependencies = [ [[package]] name = "ic-management-canister-types" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f3af3543f6d0cbdecd2dcdfd4737ada2bd42d935cc787eec22090c96492c76" +checksum = "8b5a939a84adbc30769d47e5de72c7b9f3713284e3ac87df4eb24795677a8df8" dependencies = [ "candid", "serde", @@ -1647,8 +1648,9 @@ dependencies = [ [[package]] name = "ic-transport-types" -version = "0.42.0" -source = "git+https://github.com/dfinity/agent-rs?rev=f34acedb5539838ffdbd4cf49a0832303977293f#f34acedb5539838ffdbd4cf49a0832303977293f" +version = "0.44.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fec6355d0a542bfe484eb36343b6570047394124918cb8b435e22241c65427" dependencies = [ "candid", "hex", @@ -1664,8 +1666,9 @@ dependencies = [ [[package]] name = "ic-utils" -version = "0.42.0" -source = "git+https://github.com/dfinity/agent-rs?rev=f34acedb5539838ffdbd4cf49a0832303977293f#f34acedb5539838ffdbd4cf49a0832303977293f" +version = "0.44.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc35f1cf9c5053b108b24fbf24eed544dc37647a95b183e2e1c7dfb93da23d32" dependencies = [ "async-trait", "candid", @@ -1681,7 +1684,6 @@ dependencies = [ "strum_macros", "thiserror 2.0.12", "time", - "tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index dcc6ad1..b0eb89c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,8 +44,8 @@ reqwest = "0.12" ic-cdk = "0.17" ic-cdk-macros = "0.17" -ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "f34acedb5539838ffdbd4cf49a0832303977293f" } -ic-utils = { git = "https://github.com/dfinity/agent-rs", rev = "f34acedb5539838ffdbd4cf49a0832303977293f" } +ic-agent = "0.44" +ic-utils = "0.44" candid = "0.10" pocket-ic = "6.0" assert_matches = "1" diff --git a/examples/http-gateway/canister/src/custom_assets/src/lib.rs b/examples/http-gateway/canister/src/custom_assets/src/lib.rs index 8b58218..8bc5ba5 100644 --- a/examples/http-gateway/canister/src/custom_assets/src/lib.rs +++ b/examples/http-gateway/canister/src/custom_assets/src/lib.rs @@ -111,44 +111,29 @@ fn current_chunk_index(resp: &HttpResponse) -> usize { } fn chunk_corruption_requested(req: &HttpRequest) -> Option { - if let Some(corrupted_chunk_index) = get_header_value(req.headers(), "Test-CorruptChunkAtIndex") - { - Some( - corrupted_chunk_index - .parse() - .expect("invalid index of chunk to corrupt"), - ) - } else { - None - } + get_header_value(req.headers(), "Test-CorruptChunkAtIndex").map(|corrupted_chunk_index| { + corrupted_chunk_index + .parse() + .expect("invalid index of chunk to corrupt") + }) } fn cert_corruption_requested(req: &HttpRequest) -> Option { - if let Some(corrupted_cert_chunk_index) = - get_header_value(req.headers(), "Test-CorruptCertificateAtIndex") - { - Some( + get_header_value(req.headers(), "Test-CorruptCertificateAtIndex").map( + |corrupted_cert_chunk_index| { corrupted_cert_chunk_index .parse() - .expect("invalid index of chunk to corrupt the certificate"), - ) - } else { - None - } + .expect("invalid index of chunk to corrupt the certificate") + }, + ) } fn chunk_swap_requested(req: &HttpRequest) -> Option { - if let Some(chunk_index_to_swap) = - get_header_value(req.headers(), "Test-SwapChunkAtIndexWithNext") - { - Some( - chunk_index_to_swap - .parse() - .expect("invalid index of chunk to swap"), - ) - } else { - None - } + get_header_value(req.headers(), "Test-SwapChunkAtIndexWithNext").map(|chunk_index_to_swap| { + chunk_index_to_swap + .parse() + .expect("invalid index of chunk to swap") + }) } fn get_header_value(headers: &[HeaderField], header_name: &str) -> Option { @@ -178,10 +163,10 @@ fn get_content_range_begin(content_range_header_value: &str) -> usize { content_range_header_value ); } - let range_begin = str_value_parts[0].parse::().expect(&format!( - "Invalid range_begin in: {}", - content_range_header_value - )); + let range_begin = str_value_parts[0] + .parse::() + .unwrap_or_else(|_| panic!("Invalid range_begin in: {content_range_header_value}")); + // Note: skipping the check whether range_end and total_length are sane. range_begin } diff --git a/packages/ic-http-gateway/src/client/http_gateway_client.rs b/packages/ic-http-gateway/src/client/http_gateway_client.rs index 71a4b75..3ab5e29 100644 --- a/packages/ic-http-gateway/src/client/http_gateway_client.rs +++ b/packages/ic-http-gateway/src/client/http_gateway_client.rs @@ -14,7 +14,7 @@ pub struct HttpGatewayClient { agent: Agent, } -impl HttpGatewayClient { +impl<'a> HttpGatewayClient { pub fn new(args: HttpGatewayClientArgs) -> Self { Self { agent: args.agent } } @@ -23,7 +23,7 @@ impl HttpGatewayClient { Default::default() } - pub fn request(&self, args: HttpGatewayRequestArgs) -> HttpGatewayRequestBuilder { + pub fn request(&'a self, args: HttpGatewayRequestArgs) -> HttpGatewayRequestBuilder<'a> { HttpGatewayRequestBuilder::new(HttpGatewayRequestBuilderArgs { request_args: args, agent: &self.agent,