Replace custom hyper client with reqwest (#593)

* [DNM] Replace custom hyper client with reqwest

* Fix runtime error
This commit is contained in:
Quentin Le Sceller
2021-05-04 11:13:38 -04:00
committed by GitHub
parent bdc5bd748a
commit 83fd8ffc86
11 changed files with 297 additions and 192 deletions
+10 -6
View File
@@ -13,7 +13,7 @@
// limitations under the License.
/// HTTP Wallet 'plugin' implementation
use crate::client_utils::{Client, ClientError};
use crate::client_utils::{Client, ClientError, ClientErrorKind};
use crate::libwallet::slate_versions::{SlateVersion, VersionedSlate};
use crate::libwallet::{Error, ErrorKind, Slate};
use crate::SlateSender;
@@ -163,11 +163,15 @@ impl HttpSlateSender {
where
IN: Serialize,
{
let mut client = Client::new();
if self.use_socks {
client.use_socks = true;
client.socks_proxy_addr = self.socks_proxy_addr;
}
let client =
if self.use_socks {
Client::new()
} else {
Client::with_socks_proxy(self.socks_proxy_addr.ok_or_else(|| {
ClientErrorKind::Internal("No socks proxy address set".into())
})?)
}
.map_err(|_| ClientErrorKind::Internal("Unable to create http client".into()))?;
let req = client.create_post_request(url, api_secret, &input)?;
let res = client.send_request(req)?;
Ok(res)
+1 -1
View File
@@ -345,7 +345,7 @@ impl SlateReceiver for KeybaseAllChannels {
account: &str,
node_api_secret: Option<String>,
) -> Result<(), Error> {
let node_client = HTTPNodeClient::new(&config.check_node_api_http_addr, node_api_secret);
let node_client = HTTPNodeClient::new(&config.check_node_api_http_addr, node_api_secret)?;
let mut wallet =
Box::new(DefaultWalletImpl::<'static, HTTPNodeClient>::new(node_client).unwrap())
as Box<