From 8ba828b41e2609c91d993aec464035d62320fdad Mon Sep 17 00:00:00 2001 From: Raashid Anwar Date: Sun, 31 Dec 2023 18:15:12 +0530 Subject: fix(http_client): Fix Deno.createHttpClient to accept poolIdleTimeout parameter (#21603) Fixed the bug `Deno.createHttpClient` to accept `poolIdleTimeout` parameter. Fixes https://github.com/denoland/deno/issues/21546 --- ext/fetch/Cargo.toml | 1 + ext/fetch/lib.rs | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'ext/fetch') diff --git a/ext/fetch/Cargo.toml b/ext/fetch/Cargo.toml index af4af29a6..2e3283b08 100644 --- a/ext/fetch/Cargo.toml +++ b/ext/fetch/Cargo.toml @@ -23,5 +23,6 @@ http_v02.workspace = true pin-project.workspace = true reqwest.workspace = true serde.workspace = true +serde_json.workspace = true tokio.workspace = true tokio-util = { workspace = true, features = ["io"] } diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 6a2ac2ef9..ee8f30b59 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -789,13 +789,6 @@ impl HttpClientResource { } } -#[derive(Deserialize, Debug, Clone)] -#[serde(rename_all = "camelCase")] -pub enum PoolIdleTimeout { - State(bool), - Specify(u64), -} - #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct CreateHttpClientArgs { @@ -804,7 +797,7 @@ pub struct CreateHttpClientArgs { cert_chain: Option, private_key: Option, pool_max_idle_per_host: Option, - pool_idle_timeout: Option, + pool_idle_timeout: Option, #[serde(default = "default_true")] http1: bool, #[serde(default = "default_true")] @@ -867,9 +860,12 @@ where pool_max_idle_per_host: args.pool_max_idle_per_host, pool_idle_timeout: args.pool_idle_timeout.and_then( |timeout| match timeout { - PoolIdleTimeout::State(true) => None, - PoolIdleTimeout::State(false) => Some(None), - PoolIdleTimeout::Specify(specify) => Some(Some(specify)), + serde_json::Value::Bool(true) => None, + serde_json::Value::Bool(false) => Some(None), + serde_json::Value::Number(specify) => { + Some(Some(specify.as_u64().unwrap_or_default())) + } + _ => Some(None), }, ), http1: args.http1, -- cgit v1.2.3