From 3888ca84dc2696a1c81bcc152395c7d9db6e7f66 Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Thu, 16 Jan 2020 09:27:52 +0000 Subject: [PATCH] source: update to new reqwest blocking API --- src/errors.rs | 8 ++++---- src/source.rs | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index a167b785d425..73949ef4f4ab 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -16,9 +16,9 @@ use error_chain::error_chain; error_chain! { foreign_links { - Io(::std::io::Error); - Reqwest(::reqwest::Error); - Url(::reqwest::UrlError); - Nix(::nix::Error); + Io(std::io::Error); + Reqwest(reqwest::Error); + Url(url::ParseError); + Nix(nix::Error); } } diff --git a/src/source.rs b/src/source.rs index ce8853d0dd8d..d868074ebb92 100644 --- a/src/source.rs +++ b/src/source.rs @@ -13,7 +13,7 @@ // limitations under the License. use error_chain::bail; -use reqwest::{StatusCode, Url}; +use reqwest::{blocking, StatusCode, Url}; use serde::Deserialize; use std::collections::HashMap; use std::fmt::{Display, Formatter}; @@ -156,7 +156,7 @@ impl Display for UrlLocation { impl ImageLocation for UrlLocation { fn sources(&self) -> Result> { - let client = reqwest::Client::new(); + let client = blocking::Client::new(); // fetch signature let mut resp = client @@ -240,9 +240,8 @@ impl Display for StreamLocation { impl ImageLocation for StreamLocation { fn sources(&self) -> Result> { - let client = reqwest::Client::new(); - // fetch and parse stream metadata + let client = blocking::Client::new(); let stream = fetch_stream(client, &self.stream_url)?; // descend it @@ -287,8 +286,8 @@ pub fn list_stream(config: &ListStreamConfig) -> Result<()> { } // fetch stream metadata + let client = blocking::Client::new(); let stream_url = build_stream_url(&config.stream, config.stream_base_url.as_ref())?; - let client = reqwest::Client::new(); let stream = fetch_stream(client, &stream_url)?; // walk formats @@ -343,7 +342,7 @@ fn build_stream_url(stream: &str, base_url: Option<&Url>) -> Result { } /// Fetch and parse stream metadata. -fn fetch_stream(client: reqwest::Client, url: &Url) -> Result { +fn fetch_stream(client: blocking::Client, url: &Url) -> Result { // fetch stream metadata let resp = client .get(url.clone()) -- 2.24.1