diff --git a/crates/nu-command/src/network/http/client.rs b/crates/nu-command/src/network/http/client.rs index 8dd4cc5601..62dd693627 100644 --- a/crates/nu-command/src/network/http/client.rs +++ b/crates/nu-command/src/network/http/client.rs @@ -525,7 +525,7 @@ pub fn request_set_timeout( mut request: Request, ) -> Result { if let Some(timeout) = timeout { - let val = timeout.as_i64()?; + let val = timeout.as_duration()?; if val.is_negative() || val < 1 { return Err(ShellError::TypeMismatch { err_message: "Timeout value must be an int and larger than 0".to_string(), @@ -533,7 +533,7 @@ pub fn request_set_timeout( }); } - request = request.timeout(Duration::from_secs(val as u64)); + request = request.timeout(Duration::from_nanos(val as u64)); } Ok(request) diff --git a/crates/nu-command/src/network/http/delete.rs b/crates/nu-command/src/network/http/delete.rs index 27b43e2b76..b13b3846e2 100644 --- a/crates/nu-command/src/network/http/delete.rs +++ b/crates/nu-command/src/network/http/delete.rs @@ -43,8 +43,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/get.rs b/crates/nu-command/src/network/http/get.rs index f348cc9fd6..8260f76c66 100644 --- a/crates/nu-command/src/network/http/get.rs +++ b/crates/nu-command/src/network/http/get.rs @@ -38,8 +38,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/head.rs b/crates/nu-command/src/network/http/head.rs index 37d6c46ba9..99c77101af 100644 --- a/crates/nu-command/src/network/http/head.rs +++ b/crates/nu-command/src/network/http/head.rs @@ -38,8 +38,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/options.rs b/crates/nu-command/src/network/http/options.rs index 5c34be4041..cd86b5349a 100644 --- a/crates/nu-command/src/network/http/options.rs +++ b/crates/nu-command/src/network/http/options.rs @@ -37,8 +37,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/patch.rs b/crates/nu-command/src/network/http/patch.rs index eeebaf55a8..b062282b84 100644 --- a/crates/nu-command/src/network/http/patch.rs +++ b/crates/nu-command/src/network/http/patch.rs @@ -39,8 +39,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/post.rs b/crates/nu-command/src/network/http/post.rs index f38f7aeed3..fbe780294b 100644 --- a/crates/nu-command/src/network/http/post.rs +++ b/crates/nu-command/src/network/http/post.rs @@ -39,8 +39,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named( diff --git a/crates/nu-command/src/network/http/put.rs b/crates/nu-command/src/network/http/put.rs index 0494f5ea0e..b3bf8b72d5 100644 --- a/crates/nu-command/src/network/http/put.rs +++ b/crates/nu-command/src/network/http/put.rs @@ -39,8 +39,8 @@ impl Command for SubCommand { ) .named( "max-time", - SyntaxShape::Int, - "timeout period in seconds", + SyntaxShape::Duration, + "max duration before timeout occurs", Some('m'), ) .named(