mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 23:42:50 +00:00
Merge branch 'master' into header-and-querystring-from-file
This commit is contained in:
commit
0817ddefa6
@ -81,11 +81,15 @@ environment variable is to rename the binary to either http or https.
|
|||||||
.BR REQUESTS_CA_BUNDLE ", " CURL_CA_BUNDLE
|
.BR REQUESTS_CA_BUNDLE ", " CURL_CA_BUNDLE
|
||||||
Sets a custom CA bundle path.
|
Sets a custom CA bundle path.
|
||||||
.TP
|
.TP
|
||||||
.B HTTPS_PROXY
|
.BR http_proxy "=[protocol://]<host>[:port]"
|
||||||
|
Sets the proxy server to use for HTTP.
|
||||||
|
.TP
|
||||||
|
.BR HTTPS_PROXY "=[protocol://]<host>[:port]"
|
||||||
Sets the proxy server to use for HTTPS.
|
Sets the proxy server to use for HTTPS.
|
||||||
.TP
|
.TP
|
||||||
.B http_proxy
|
.B NO_PROXY
|
||||||
Sets the proxy server to use for HTTP.
|
List of comma-separated hosts for which to ignore the other proxy environment
|
||||||
|
variables. "*" matches all host names.
|
||||||
.TP
|
.TP
|
||||||
.B NETRC
|
.B NETRC
|
||||||
Location of the .netrc file.
|
Location of the .netrc file.
|
||||||
|
12
doc/xh.1
12
doc/xh.1
@ -1,4 +1,4 @@
|
|||||||
.TH XH 1 2022-11-13 0.17.0 "User Commands"
|
.TH XH 1 2022-12-13 0.17.0 "User Commands"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
xh \- Friendly and fast tool for sending HTTP requests
|
xh \- Friendly and fast tool for sending HTTP requests
|
||||||
@ -326,11 +326,15 @@ environment variable is to rename the binary to either http or https.
|
|||||||
.BR REQUESTS_CA_BUNDLE ", " CURL_CA_BUNDLE
|
.BR REQUESTS_CA_BUNDLE ", " CURL_CA_BUNDLE
|
||||||
Sets a custom CA bundle path.
|
Sets a custom CA bundle path.
|
||||||
.TP
|
.TP
|
||||||
.B HTTPS_PROXY
|
.BR http_proxy "=[protocol://]<host>[:port]"
|
||||||
|
Sets the proxy server to use for HTTP.
|
||||||
|
.TP
|
||||||
|
.BR HTTPS_PROXY "=[protocol://]<host>[:port]"
|
||||||
Sets the proxy server to use for HTTPS.
|
Sets the proxy server to use for HTTPS.
|
||||||
.TP
|
.TP
|
||||||
.B http_proxy
|
.B NO_PROXY
|
||||||
Sets the proxy server to use for HTTP.
|
List of comma-separated hosts for which to ignore the other proxy environment
|
||||||
|
variables. "*" matches all host names.
|
||||||
.TP
|
.TP
|
||||||
.B NETRC
|
.B NETRC
|
||||||
Location of the .netrc file.
|
Location of the .netrc file.
|
||||||
|
21
src/cli.rs
21
src/cli.rs
@ -814,7 +814,7 @@ fn generate_manpages(mut app: clap::Command, rest_args: Vec<String>) -> Error {
|
|||||||
header.push(roman("] | "));
|
header.push(roman("] | "));
|
||||||
header.push(italic("TOKEN"));
|
header.push(italic("TOKEN"));
|
||||||
} else {
|
} else {
|
||||||
header.push(italic(&value.join(" ")));
|
header.push(italic(value.join(" ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut body = vec![];
|
let mut body = vec![];
|
||||||
@ -1050,13 +1050,18 @@ impl FromStr for Timeout {
|
|||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
fn from_str(sec: &str) -> anyhow::Result<Timeout> {
|
fn from_str(sec: &str) -> anyhow::Result<Timeout> {
|
||||||
let pos_sec: f64 = match sec.parse::<f64>() {
|
match f64::from_str(sec) {
|
||||||
Ok(sec) if sec.is_sign_positive() => sec,
|
Ok(s) if !s.is_nan() => {
|
||||||
_ => return Err(anyhow!("Invalid seconds as connection timeout")),
|
if s.is_sign_negative() {
|
||||||
};
|
Err(anyhow!("Connection timeout is negative"))
|
||||||
|
} else if s >= Duration::MAX.as_secs_f64() || s.is_infinite() {
|
||||||
let dur = Duration::from_secs_f64(pos_sec);
|
Err(anyhow!("Connection timeout is too big"))
|
||||||
Ok(Timeout(dur))
|
} else {
|
||||||
|
Ok(Timeout(Duration::from_secs_f64(s)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => Err(anyhow!("Connection timeout is not a valid number")),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ impl RequestItems {
|
|||||||
file_type,
|
file_type,
|
||||||
file_name_header,
|
file_name_header,
|
||||||
} => {
|
} => {
|
||||||
let mut part = file_to_part(expand_tilde(&file_name))?;
|
let mut part = file_to_part(expand_tilde(file_name))?;
|
||||||
if let Some(file_type) = file_type {
|
if let Some(file_type) = file_type {
|
||||||
part = part.mime_str(&file_type)?;
|
part = part.mime_str(&file_type)?;
|
||||||
}
|
}
|
||||||
|
39
tests/cli.rs
39
tests/cli.rs
@ -14,7 +14,6 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use assert_cmd::cmd::Command;
|
use assert_cmd::cmd::Command;
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use predicates::boolean::PredicateBooleanExt;
|
|
||||||
use predicates::function::function;
|
use predicates::function::function;
|
||||||
use predicates::str::contains;
|
use predicates::str::contains;
|
||||||
use tempfile::{tempdir, NamedTempFile, TempDir};
|
use tempfile::{tempdir, NamedTempFile, TempDir};
|
||||||
@ -666,7 +665,31 @@ fn timeout_invalid() {
|
|||||||
.args(["--timeout=-0.01", "--offline", ":"])
|
.args(["--timeout=-0.01", "--offline", ":"])
|
||||||
.assert()
|
.assert()
|
||||||
.failure()
|
.failure()
|
||||||
.stderr(contains("Invalid seconds as connection timeout"));
|
.stderr(contains("Connection timeout is negative"));
|
||||||
|
|
||||||
|
get_command()
|
||||||
|
.args(["--timeout=18446744073709552000", "--offline", ":"])
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(contains("Connection timeout is too big"));
|
||||||
|
|
||||||
|
get_command()
|
||||||
|
.args(["--timeout=inf", "--offline", ":"])
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(contains("Connection timeout is too big"));
|
||||||
|
|
||||||
|
get_command()
|
||||||
|
.args(["--timeout=NaN", "--offline", ":"])
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(contains("Connection timeout is not a valid number"));
|
||||||
|
|
||||||
|
get_command()
|
||||||
|
.args(["--timeout=SEC", "--offline", ":"])
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(contains("Connection timeout is not a valid number"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -984,7 +1007,7 @@ fn netrc_file_user_password_auth() {
|
|||||||
|
|
||||||
let homedir = TempDir::new().unwrap();
|
let homedir = TempDir::new().unwrap();
|
||||||
let netrc_path = homedir.path().join(netrc_file);
|
let netrc_path = homedir.path().join(netrc_file);
|
||||||
let mut netrc = File::create(&netrc_path).unwrap();
|
let mut netrc = File::create(netrc_path).unwrap();
|
||||||
writeln!(
|
writeln!(
|
||||||
netrc,
|
netrc,
|
||||||
"machine {}\nlogin user\npassword pass",
|
"machine {}\nlogin user\npassword pass",
|
||||||
@ -1127,9 +1150,12 @@ fn proxy_multiple_valid_proxies() {
|
|||||||
cmd.assert().success();
|
cmd.assert().success();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "online-tests")]
|
// temporarily disabled for builds not using rustls
|
||||||
|
#[cfg(all(feature = "online-tests", feature = "rustls"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_default_yes() {
|
fn verify_default_yes() {
|
||||||
|
use predicates::boolean::PredicateBooleanExt;
|
||||||
|
|
||||||
get_command()
|
get_command()
|
||||||
.args(["-v", "https://self-signed.badssl.com"])
|
.args(["-v", "https://self-signed.badssl.com"])
|
||||||
.assert()
|
.assert()
|
||||||
@ -1139,9 +1165,12 @@ fn verify_default_yes() {
|
|||||||
.stderr(contains("UnknownIssuer").or(contains("self signed certificate")));
|
.stderr(contains("UnknownIssuer").or(contains("self signed certificate")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "online-tests")]
|
// temporarily disabled for builds not using rustls
|
||||||
|
#[cfg(all(feature = "online-tests", feature = "rustls"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_explicit_yes() {
|
fn verify_explicit_yes() {
|
||||||
|
use predicates::boolean::PredicateBooleanExt;
|
||||||
|
|
||||||
get_command()
|
get_command()
|
||||||
.args(["-v", "--verify=yes", "https://self-signed.badssl.com"])
|
.args(["-v", "--verify=yes", "https://self-signed.badssl.com"])
|
||||||
.assert()
|
.assert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user