client: use build_authority in build_uri

so we don't need to also duplicate the IPv6 bracket logic

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-05-06 08:55:44 +02:00
committed by Dietmar Maurer
parent 78bf292343
commit 25d78b1068
2 changed files with 14 additions and 19 deletions

View File

@ -27,7 +27,7 @@ use crate::tools::{
};
// Build a http::uri::Authority ("host:port"), use '[..]' around IPv6 addresses
fn build_authority(host: &str, port: u16) -> Result<Authority, Error> {
pub(crate) fn build_authority(host: &str, port: u16) -> Result<Authority, Error> {
let bytes = host.as_bytes();
let len = bytes.len();
let authority = if len > 3 && bytes.contains(&b':') && bytes[0] != b'[' && bytes[len-1] != b']' {