Switch to using ureq instead of reqwest

This commit is contained in:
MinusGix 2022-03-21 20:23:25 -05:00
parent 8484d4527d
commit 23ef6910bc
7 changed files with 102 additions and 306 deletions

380
Cargo.lock generated
View File

@ -288,12 +288,6 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "calloop"
version = "0.9.3"
@ -344,6 +338,12 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "chunked_transfer"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]]
name = "clipboard-win"
version = "3.1.1"
@ -1532,25 +1532,6 @@ dependencies = [
"memmap2 0.3.1",
]
[[package]]
name = "h2"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "hashbrown"
version = "0.9.1"
@ -1612,77 +1593,6 @@ dependencies = [
"notify 4.0.17",
]
[[package]]
name = "http"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]]
name = "http-body"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6"
dependencies = [
"bytes",
"http",
"pin-project-lite",
]
[[package]]
name = "httparse"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503"
[[package]]
name = "httpdate"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"h2",
"http",
"http-body",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper",
"native-tls",
"tokio",
"tokio-native-tls",
]
[[package]]
name = "ident_case"
version = "1.0.1"
@ -1846,12 +1756,6 @@ dependencies = [
"libc",
]
[[package]]
name = "ipnet"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
[[package]]
name = "itertools"
version = "0.10.3"
@ -2026,7 +1930,6 @@ dependencies = [
"parking_lot",
"rayon",
"regex",
"reqwest",
"serde 1.0.130",
"serde_json",
"sled",
@ -2039,6 +1942,7 @@ dependencies = [
"toml",
"unicode-segmentation",
"unicode-width",
"ureq",
"usvg",
"uuid",
"xi-rope",
@ -2070,10 +1974,10 @@ dependencies = [
"notify 5.0.0-pre.13",
"parking_lot",
"regex",
"reqwest",
"serde 1.0.130",
"serde_json",
"toml",
"ureq",
"wasmer",
"wasmer-wasi",
"which",
@ -2129,7 +2033,6 @@ dependencies = [
"parking_lot",
"rayon",
"regex",
"reqwest",
"serde 1.0.130",
"serde_json",
"sled",
@ -2449,12 +2352,6 @@ dependencies = [
"objc",
]
[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "minimal-lexical"
version = "0.1.2"
@ -2604,24 +2501,6 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce8b389a86cabeb0d8b33a61e60f3cbb4de38914342fe274e69111f3b5d9c44"
[[package]]
name = "native-tls"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d"
dependencies = [
"lazy_static",
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]]
name = "ndk"
version = "0.6.0"
@ -2912,20 +2791,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
version = "0.10.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"foreign-types",
"libc",
"once_cell",
"openssl-sys",
]
[[package]]
name = "openssl-probe"
version = "0.1.4"
@ -3476,38 +3341,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "reqwest"
version = "0.11.8"
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c4e0a76dc12a116108933f6301b95e83634e0c47b0afbed6abbaa0601e99258"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"base64",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"http",
"http-body",
"hyper",
"hyper-tls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"native-tls",
"percent-encoding",
"pin-project-lite",
"serde 1.0.130",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-native-tls",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winreg",
"winapi 0.3.9",
]
[[package]]
@ -3580,6 +3425,18 @@ dependencies = [
"semver 0.11.0",
]
[[package]]
name = "rustls"
version = "0.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921"
dependencies = [
"log",
"ring",
"sct",
"webpki",
]
[[package]]
name = "rustversion"
version = "1.0.6"
@ -3617,16 +3474,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "schannel"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [
"lazy_static",
"winapi 0.3.9",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
@ -3639,35 +3486,22 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "seahash"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
[[package]]
name = "security-framework"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467"
dependencies = [
"bitflags",
"core-foundation 0.9.1",
"core-foundation-sys 0.8.2",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e"
dependencies = [
"core-foundation-sys 0.8.2",
"libc",
]
[[package]]
name = "semver"
version = "0.9.0"
@ -3770,18 +3604,6 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde 1.0.130",
]
[[package]]
name = "serde_yaml"
version = "0.8.21"
@ -3992,14 +3814,10 @@ dependencies = [
]
[[package]]
name = "socket2"
version = "0.4.2"
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516"
dependencies = [
"libc",
"winapi 0.3.9",
]
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spirv"
@ -4301,45 +4119,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
dependencies = [
"bytes",
"libc",
"memchr",
"mio 0.7.13",
"num_cpus",
"pin-project-lite",
"winapi 0.3.9",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"log",
"pin-project-lite",
"tokio",
]
[[package]]
name = "toml"
version = "0.5.8"
@ -4350,12 +4129,6 @@ dependencies = [
"serde 1.0.130",
]
[[package]]
name = "tower-service"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
version = "0.1.26"
@ -4493,12 +4266,6 @@ dependencies = [
"tree-sitter",
]
[[package]]
name = "try-lock"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "ttf-parser"
version = "0.9.0"
@ -4664,6 +4431,31 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "ureq"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9399fa2f927a3d327187cbd201480cee55bee6ac5d3c77dd27f0c6814cff16d5"
dependencies = [
"base64",
"chunked_transfer",
"flate2",
"log",
"once_cell",
"rustls",
"serde 1.0.130",
"serde_json",
"url",
"webpki",
"webpki-roots",
]
[[package]]
name = "url"
version = "2.2.2"
@ -4762,16 +4554,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "want"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
dependencies = [
"log",
"try-lock",
]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
@ -5254,6 +5036,25 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449"
dependencies = [
"webpki",
]
[[package]]
name = "wgpu"
version = "0.12.0"
@ -5435,15 +5236,6 @@ dependencies = [
"xkbcommon-dl",
]
[[package]]
name = "winreg"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "wio"
version = "0.2.2"

View File

@ -14,7 +14,7 @@ rayon = "1.5.1"
diff = "0.1.12"
libloading = "0.7"
flate2 = "1.0.22"
reqwest = { version = "0.11", features = ["blocking", "json"] }
ureq = { version = "2.4.0", features = ["json"] }
hashbrown = "0.11.2"
sled = "0.34.7"
base64 = "0.13.0"

View File

@ -132,9 +132,9 @@ pub fn reload_env(&self, env: &mut Env) {
}
fn load_plugin_descriptions() -> Result<Vec<PluginDescription>> {
let plugins: Vec<String> =
reqwest::blocking::get("https://lapce.github.io/plugins.json")?
.json()?;
let plugins: Vec<String> = ureq::get("https://lapce.github.io/plugins.json")
.call()?
.into_json()?;
let plugins: Vec<PluginDescription> = plugins
.iter()
.filter_map(|plugin| LapceData::load_plgin_description(plugin).ok())
@ -147,7 +147,7 @@ fn load_plgin_description(plugin: &str) -> Result<PluginDescription> {
"https://raw.githubusercontent.com/{}/master/plugin.toml",
plugin
);
let content = reqwest::blocking::get(url)?.text()?;
let content = ureq::get(&url).call()?.into_string()?;
let plugin: PluginDescription = toml::from_str(&content)?;
Ok(plugin)
}

View File

@ -258,11 +258,13 @@ fn start(&self, workspace: LapceWorkspace) -> Result<()> {
.join(format!("lapce-proxy-{}", VERSION));
if !local_proxy_file.exists() {
let url = format!("https://github.com/lapce/lapce/releases/download/v{VERSION}/lapce-proxy-linux.gz");
let mut resp =
reqwest::blocking::get(url).expect("request failed");
let mut data = ureq::get(&url)
.call()
.expect("request failed")
.into_reader();
let mut out = std::fs::File::create(&local_proxy_file)
.expect("failed to create file");
let mut gz = GzDecoder::new(&mut resp);
let mut gz = GzDecoder::new(&mut data);
std::io::copy(&mut gz, &mut out)
.expect("failed to copy content");
}

View File

@ -11,7 +11,7 @@ grep-searcher = "0.1.8"
grep-matcher = "0.1.5"
grep-regex = "0.1.9"
ignore = "0.4.18"
reqwest = { version = "0.11", features = ["blocking"] }
ureq = { version = "2.4.0", features = ["json"] }
wasmer = "2.1.1"
wasmer-wasi = "2.1.1"
directories = "4.0.1"

View File

@ -137,7 +137,7 @@ pub fn install_plugin(
"https://raw.githubusercontent.com/{}/master/{}",
plugin.repository, plugin.wasm
);
let mut resp = reqwest::blocking::get(url)?;
let mut resp = ureq::get(&url).call()?.into_reader();
let mut file = std::fs::OpenOptions::new()
.create(true)
.truncate(true)
@ -289,7 +289,10 @@ fn host_handle_notification(plugin_env: &PluginEnv) {
);
}
PluginNotification::DownloadFile { url, path } => {
let mut resp = reqwest::blocking::get(url).expect("request failed");
let mut resp = ureq::get(&url)
.call()
.expect("request failed")
.into_reader();
let mut out = std::fs::File::create(
plugin_env.desc.dir.clone().unwrap().join(path),
)

View File

@ -13,7 +13,6 @@ rayon = "1.5.1"
diff = "0.1.12"
libloading = "0.7"
flate2 = "1.0.22"
reqwest = { version = "0.11", features = ["blocking", "json"] }
hashbrown = "0.11.2"
sled = "0.34.7"
base64 = "0.13.0"