There are several internet clients available in R so it depends on what you are using.
A pac
file is not a proxy server. It is just a piece of JavaScript that the client needs to execute to calculate the required proxy server for a given URL. So your code above is definitely wrong.
Companies use pac
when different proxy servers are required to connect different hosts (e.g. a special intranet proxy). Have a look at the source code if your pac file to see what's going on. The curl
package implements an actual PAC client in the ie_get_proxy_for_url()
function. So you could wrap that to automatically find and set the correct proxy for a curl handle (see also blog):
curl_with_proxy <- function(url, verbose = TRUE){
proxy <- ie_get_proxy_for_url(url)
h <- new_handle(verbose = verbose, proxy = proxy)
curl(url, handle = h)
}
And then use it like this:
con <- curl_with_proxy("https://httpbin.org/get")
readLines(con)
If it turns out your pac
file simply returns proxy.<my.domain>:8080
for any URL you might be able to set in an environment variable, but this only works for libcurl
based clients:
Sys.setenv(http_proxy_user = "userid:password")
Sys.setenv(http_proxy = "proxy.<my.domain>:8080")
If you can't get it to work, please describe your problem in this github issue. Perhaps your case can help us improve this part of the curl
package.