From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 59D4C79DD8 for ; Thu, 6 May 2021 09:02:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 455FB1BF59 for ; Thu, 6 May 2021 09:02:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6991E1BF4A for ; Thu, 6 May 2021 09:02:01 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 38ACB4298D for ; Thu, 6 May 2021 09:02:01 +0200 (CEST) Date: Thu, 6 May 2021 09:01:46 +0200 (CEST) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Wolfgang Bumiller Message-ID: <228044467.236.1620284506924@webmail.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.5-Rev10 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.240 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [http.rs, proxmox.com] Subject: Re: [pbs-devel] [PATCH backup] client: use build_authority in build_uri X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2021 07:02:33 -0000 In general a good idea, but we now merge code from two independent http client implementation (making them dependent)? > On 05/06/2021 8:55 AM Wolfgang Bumiller wrote: > > > so we don't need to also duplicate the IPv6 bracket logic > > Signed-off-by: Wolfgang Bumiller > --- > Just a little cleanup since we added 2 different bracket codes for ipv6 > in the recent commits... > > src/client/http_client.rs | 31 +++++++++++++------------------ > src/tools/http.rs | 2 +- > 2 files changed, 14 insertions(+), 19 deletions(-) > > diff --git a/src/client/http_client.rs b/src/client/http_client.rs > index f2fada23..785626e8 100644 > --- a/src/client/http_client.rs > +++ b/src/client/http_client.rs > @@ -26,7 +26,10 @@ use crate::tools::{ > self, > BroadcastFuture, > DEFAULT_ENCODE_SET, > - http::HttpsConnector, > + http::{ > + build_authority, > + HttpsConnector, > + }, > }; > > /// Timeout used for several HTTP operations that are expected to finish quickly but may block in > @@ -274,23 +277,15 @@ fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(Stri > } > > fn build_uri(server: &str, port: u16, path: &str, query: Option) -> Result { > - let path = path.trim_matches('/'); > - let bytes = server.as_bytes(); > - let len = bytes.len(); > - let uri = if len > 3 && bytes.contains(&b':') && bytes[0] != b'[' && bytes[len-1] != b']' { > - if let Some(query) = query { > - format!("https://[{}]:{}/{}?{}", server, port, path, query) > - } else { > - format!("https://[{}]:{}/{}", server, port, path) > - } > - } else { > - if let Some(query) = query { > - format!("https://{}:{}/{}?{}", server, port, path, query) > - } else { > - format!("https://{}:{}/{}", server, port, path) > - } > - }; > - Ok(uri.parse()?) > + let builder = Uri::builder() > + .scheme("https") > + .authority(build_authority(server, port)?); > + match query { > + Some(query) => builder.path_and_query(format!("{}?{}", path, query)), > + None => builder.path_and_query(path), > + } > + .build() > + .map_err(Error::from) > } > > impl HttpClient { > diff --git a/src/tools/http.rs b/src/tools/http.rs > index cfdd9b16..9adfc118 100644 > --- a/src/tools/http.rs > +++ b/src/tools/http.rs > @@ -29,7 +29,7 @@ use crate::tools::{ > }; > > // Build a http::uri::Authority ("host:port"), use '[..]' around IPv6 addresses > -fn build_authority(host: &str, port: u16) -> Result { > +pub(crate) fn build_authority(host: &str, port: u16) -> Result { > let bytes = host.as_bytes(); > let len = bytes.len(); > let authority = if len > 3 && bytes.contains(&b':') && bytes[0] != b'[' && bytes[len-1] != b']' { > -- > 2.20.1 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel