Replace reqwest with ureq (#112)

* Replace reqwest with ureq

* Reqwest-free rustfm-scrobble
This commit is contained in:
Antoine Gersant 2020-12-13 15:53:31 -08:00 committed by GitHub
parent dd92d3e6eb
commit 9c45ad5238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 178 additions and 904 deletions

1065
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ diesel_migrations = { version = "1.4", features = ["sqlite"] }
getopts = "0.2.15"
id3 = "0.5.1"
libsqlite3-sys = { version = "0.18", features = ["bundled", "bundled-windows"], optional = true }
rustfm-scrobble = "^1"
rustfm-scrobble = "1.1"
lewton = "0.10.1"
log = "0.4.5"
metaflac = "0.2.3"
@ -31,7 +31,6 @@ pbkdf2 = "0.6"
rand = "0.7"
rayon = "1.3"
regex = "1.3.9"
reqwest = "0.9.2"
rocket = { version = "0.4.5", optional = true }
serde = { version = "1.0.111", features = ["derive"] }
serde_derive = "1.0.111"
@ -40,6 +39,7 @@ simplelog = "0.8.0"
thiserror = "1.0.19"
time = "0.1"
toml = "0.5"
ureq = "1.5"
url = "2.1"
[dependencies.diesel]

View file

@ -1,9 +1,9 @@
use anyhow::*;
use diesel::prelude::*;
use log::{error, info};
use reqwest;
use std::thread;
use std::time;
use ureq;
use super::*;
use crate::db::DB;
@ -27,18 +27,17 @@ impl Manager {
}
let full_url = format!("{}?host={}", DDNS_UPDATE_URL, &config.host);
let client = reqwest::ClientBuilder::new().build()?;
let response = client
.get(full_url.as_str())
.basic_auth(config.username, Some(config.password))
.send()?;
let response = ureq::get(full_url.as_str())
.auth(&config.username, &config.password)
.call();
if !response.status().is_success() {
if !response.ok() {
bail!(
"DDNS update query failed with status code: {}",
response.status()
);
}
Ok(())
}