method argument in download.file function is set by the option download.file.method. So, another way to go is to change this option to change the default behaviour depending where you code is run.
Here how I would to it. (It is for example but it should work)
Using the config package works well with Connect as mentionned by @edgararuiz because the R_CONFIG_ACTIVE environnment variable is set by default to rsconnect on an RStudio Connect server.
You can use this behaviour at your advantage, without config either in your code.
if (Sys.getenv("R_CONFIG_ACTIVE") == "rsconnect") options(download.file.method = "wget")
or setting this option once and for all in your rsconnect server for the R installation if it is not the only app with this behaviour.
However, it is possible to take advantage of config to keep all configuration with the code. Put somewhere in your code
option(download.file.method = config::get("download_method"))
with a config.yml like this (I used wininet on local config because I am on windows)
default:
download_method: "wininet"
rsconnect:
download_method: "wget"
Using a system like this but combining with rlang capabilities like @edgararuiz suggested is powerful. I let you play with all that I think you get the idea. I hope it helps.