Add https_only() for ClientBuilder (#1102)

Closes #980
This commit is contained in:
Martin André
2020-12-09 19:40:46 +01:00
committed by GitHub
parent 474d9eff9b
commit 541d0c2aba
4 changed files with 70 additions and 0 deletions

View File

@@ -288,3 +288,25 @@ fn test_blocking_inside_a_runtime() {
let _should_panic = reqwest::blocking::get(&url);
});
}
#[cfg(feature = "default-tls")]
#[test]
fn test_allowed_methods_blocking() {
let resp = reqwest::blocking::Client::builder()
.https_only(true)
.build()
.expect("client builder")
.get("https://google.com")
.send();
assert_eq!(resp.is_err(), false);
let resp = reqwest::blocking::Client::builder()
.https_only(true)
.build()
.expect("client builder")
.get("http://google.com")
.send();
assert_eq!(resp.is_err(), true);
}