public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox 3/4] http: sync: derive default user-agent from crate version
Date: Tue, 7 Mar 2023 09:40:59 +0100	[thread overview]
Message-ID: <20230307084059.nwv7zmwpdv25w2k2@fwblub> (raw)
In-Reply-To: <20230303113924.389256-4-f.gruenbichler@proxmox.com>

On Fri, Mar 03, 2023 at 12:39:23PM +0100, Fabian Grünbichler wrote:
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> if we want a fall back in case rustc is called manually, not by cargo, we could
> also use option_env!..
> 
>  proxmox-http/src/client/sync.rs | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/proxmox-http/src/client/sync.rs b/proxmox-http/src/client/sync.rs
> index 228f839..3485f84 100644
> --- a/proxmox-http/src/client/sync.rs
> +++ b/proxmox-http/src/client/sync.rs
> @@ -7,8 +7,6 @@ use http::Response;
>  use crate::HttpClient;
>  use crate::HttpOptions;
>  
> -pub const DEFAULT_USER_AGENT_STRING: &str = "proxmox-sync-http-client/0.1";
> -
>  #[derive(Default)]
>  /// Blocking HTTP client for usage with [`HttpClient`].
>  pub struct Client {
> @@ -23,12 +21,10 @@ impl Client {
>      fn agent(&self) -> Result<ureq::Agent, Error> {
>          let mut builder = ureq::AgentBuilder::new();
>  
> -        builder = builder.user_agent(
> -            self.options
> -                .user_agent
> -                .as_deref()
> -                .unwrap_or(DEFAULT_USER_AGENT_STRING),
> -        );
> +        builder = builder.user_agent(self.options.user_agent.as_deref().unwrap_or(&format!(
> +            "proxmox-sync-http-client/{}",
> +            env!("CARGO_PKG_VERSION")
> +        )));

I just realized too late that here this could actually use `concat!()`
instead of `&format!` to avoid the extra allocation.

>  
>          if let Some(proxy_config) = &self.options.proxy_config {
>              builder = builder.proxy(ureq::Proxy::new(proxy_config.to_proxy_string()?)?);
> -- 
> 2.30.2




  reply	other threads:[~2023-03-07  8:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 11:39 [pbs-devel] [PATCH proxmox 0/4] http: sync: user-agent improvements Fabian Grünbichler
2023-03-03 11:39 ` [pbs-devel] [PATCH proxmox 1/4] http: sync: set user-agent via ureq agent Fabian Grünbichler
2023-03-03 11:39 ` [pbs-devel] [PATCH proxmox 2/4] http: sync: remove redundant calls for setting User-Agent Fabian Grünbichler
2023-03-03 11:39 ` [pbs-devel] [PATCH proxmox 3/4] http: sync: derive default user-agent from crate version Fabian Grünbichler
2023-03-07  8:40   ` Wolfgang Bumiller [this message]
2023-03-03 11:39 ` [pbs-devel] [PATCH proxmox 4/4] http: sync: drop unused &self parameter Fabian Grünbichler
2023-03-07  8:31 ` [pbs-devel] applied-series: [PATCH proxmox 0/4] http: sync: user-agent improvements Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307084059.nwv7zmwpdv25w2k2@fwblub \
    --to=w.bumiller@proxmox.com \
    --cc=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal