improvement: replace reqwest with attohttpc (#999)

This commit is contained in:
David Knaack 2020-03-15 02:07:34 +01:00 committed by GitHub
parent 8479e72b3e
commit fef8cc8bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 667 deletions

View File

@ -225,10 +225,18 @@ jobs:
run: sudo apt-get install -y musl-tools
- name: Build target
if: matrix.target != 'x86_64-unknown-linux-musl'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Build target (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --features tls-vendored --target ${{ matrix.target }}
- name: Prepare build artifacts [Windows]
if: matrix.os == 'windows-latest'

730
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,10 @@ maintenance = { status = "actively-developed" }
[features]
default = ["battery", "http"]
http = ["reqwest"]
http = ["attohttpc"]
# Vendor OpenSSL, use this if you have trouble cross-compiling starship
tls-vendored = ["native-tls/vendored"]
[dependencies]
clap = "2.33.0"
@ -51,13 +54,14 @@ regex = "1.3.5"
os_info = "2.0.1"
urlencoding = "1.0.0"
open = "1.4.0"
# OpenSSL causes problems when building a MUSL release. Opting to use native SSL implementation
# see: https://github.com/richfelker/musl-cross-make/issues/65#issuecomment-509790889
reqwest = { version = "0.10.4", default-features = false, optional = true, features = ["blocking", "rustls-tls"] }
unicode-width = "0.1.7"
textwrap = "0.11.0"
term_size = "0.3.1"
# Optional/http:
attohttpc = { version = "0.12.0", optional = true, default-features = false, features = ["tls", "form"] }
native-tls = { version = "0.2", optional = true }
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -32,13 +32,12 @@ pub fn create() {
#[cfg(feature = "http")]
fn shorten_link(link: &str) -> Option<String> {
reqwest::blocking::Client::new()
.post(&format!("{}{}", GIT_IO_BASE_URL, "create"))
attohttpc::post(&format!("{}{}", GIT_IO_BASE_URL, "create"))
.form(&[("url", link)])
.send()
.and_then(|response| response.text())
.map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug))
.ok()
.and_then(|r| r.send().ok())
.and_then(|r| r.text().ok())
.map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug))
}
#[cfg(not(feature = "http"))]