mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 18:41:10 +00:00
Avoid panic when trying to fetch an invalid URL
This commit is contained in:
parent
6b5cab5db1
commit
d0052ccfb5
1 changed files with 14 additions and 12 deletions
|
@ -8,6 +8,7 @@ pub use isahc::{
|
||||||
http::{Method, Uri},
|
http::{Method, Uri},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
use smol::future::FutureExt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
pub use url::Url;
|
pub use url::Url;
|
||||||
|
|
||||||
|
@ -23,18 +24,19 @@ pub trait HttpClient: Send + Sync {
|
||||||
body: AsyncBody,
|
body: AsyncBody,
|
||||||
follow_redirects: bool,
|
follow_redirects: bool,
|
||||||
) -> BoxFuture<'a, Result<Response, Error>> {
|
) -> BoxFuture<'a, Result<Response, Error>> {
|
||||||
self.send(
|
let request = isahc::Request::builder()
|
||||||
isahc::Request::builder()
|
.redirect_policy(if follow_redirects {
|
||||||
.redirect_policy(if follow_redirects {
|
RedirectPolicy::Follow
|
||||||
RedirectPolicy::Follow
|
} else {
|
||||||
} else {
|
RedirectPolicy::None
|
||||||
RedirectPolicy::None
|
})
|
||||||
})
|
.method(Method::GET)
|
||||||
.method(Method::GET)
|
.uri(uri)
|
||||||
.uri(uri)
|
.body(body);
|
||||||
.body(body)
|
match request {
|
||||||
.unwrap(),
|
Ok(request) => self.send(request),
|
||||||
)
|
Err(error) => async move { Err(error.into()) }.boxed(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue