uri: drop anyhow::Error and improve docs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-05-17 11:21:17 +02:00
parent ca9dd7ec36
commit c9b4a4f39b
2 changed files with 6 additions and 5 deletions

View File

@ -135,7 +135,7 @@ impl hyper::service::Service<Uri> for HttpsConnector {
let proxy_authority = match build_authority(&proxy.host, proxy.port) {
Ok(authority) => authority,
Err(err) => return futures::future::err(err).boxed(),
Err(err) => return futures::future::err(err.into()).boxed(),
};
let proxy_uri = match Uri::builder()

View File

@ -1,9 +1,10 @@
use anyhow::Error;
//! URI Related helpers, such as `build_authority`
use http::uri::Authority;
use http::uri::{Authority, InvalidUri};
// Build a http::uri::Authority ("host:port"), use '[..]' around IPv6 addresses
pub fn build_authority(host: &str, port: u16) -> Result<Authority, Error> {
// Build an [`Authority`](http::uri::Authority) from a combination of `host` and `port`, ensuring that
// IPv6 addresses are enclosed in brackets.
pub fn build_authority(host: &str, port: u16) -> Result<Authority, InvalidUri> {
let bytes = host.as_bytes();
let len = bytes.len();
let authority =