https support with http fallback
This commit is contained in:
parent
eff932c415
commit
072f882490
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
/target
|
||||
TODO
|
||||
/staging
|
@ -33,11 +33,11 @@ pub fn parsehit(sc: u16, url: String, title: String) -> String {
|
||||
format!(
|
||||
"{} {} {} {}{}{}",
|
||||
fmtcode(sc),
|
||||
"|".black().bold(),
|
||||
"|".bright_black().bold(),
|
||||
url.white().underline(),
|
||||
"[".black().bold(),
|
||||
"[".bright_black().bold(),
|
||||
parsetitle(title).bright_cyan().bold(),
|
||||
"]".black().bold()
|
||||
"]".bright_black().bold()
|
||||
)
|
||||
}
|
||||
|
||||
@ -46,6 +46,6 @@ pub fn banner() {
|
||||
"{}{} {}",
|
||||
"speed".bright_cyan().bold(),
|
||||
"boat".bright_magenta().bold(),
|
||||
VERSION.black()
|
||||
VERSION.bright_black()
|
||||
);
|
||||
}
|
||||
|
@ -19,13 +19,24 @@ pub fn mkclient(redir: bool) -> Result<Client, reqwest::Error> {
|
||||
.build()
|
||||
}
|
||||
|
||||
async fn sendreq(c: &Client, use_https: bool, url: &str) -> Result<reqwest::Response, reqwest::Error> {
|
||||
let dest: String = if use_https { format!("https://{url}/") } else { format!("http://{url}/") };
|
||||
c.get(dest).send().await
|
||||
}
|
||||
|
||||
pub async fn query(
|
||||
c: Client,
|
||||
url: &str,
|
||||
codes: Vec<u16>,
|
||||
exclude: bool,
|
||||
) -> Result<(), reqwest::Error> {
|
||||
let response = c.get(format!("http://{url}/")).send().await?;
|
||||
let response: reqwest::Response;
|
||||
if let Ok(res) = sendreq(&c, true, url).await {
|
||||
response = res;
|
||||
} else {
|
||||
response = sendreq(&c, false, url).await?;
|
||||
}
|
||||
|
||||
let statcode = response.status().as_u16();
|
||||
|
||||
if codes.len() > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user