Custom headers when adding packages

Is there a way to specify headers for Pkg registry and package downloads?

My corporate proxy will only work with a specific User-Agent string. I tested it successfully with using the headers keyword-argument, but I am unsure how to specify with Pkg.

Maybe through environment variables? Any help appreciated.

Not sure but look into the functions in Pkg.PlatformEngines, like handle_auth_error?

Also, this might be relevant: Installing packages via an SSH SOCKS proxy on a compute cluster

To make sure I understand, are you suggesting that I modify the Pkg source code and build Julia?

While perusing the code, I noticed that Pkg.PlatformEngines.get_metadata_header will pick up ENV variables that start with JULIA_PKG_SERVER. So I tried setting JULIA_PKG_SERVER_USER_AGENT, but it results in a Julia-User-Agent header, which is slightly off…

I’m not saying I recommend this, or that it shouldn’t actually be addressed inside a library/package, but you could try to modify Curl.USER_AGENT:

julia> import Pkg.PlatformEngines.Downloads.Curl

julia> Curl.USER_AGENT
"curl/7.84.0 julia/1.9"