The goal is to correctly test the various possible proxy configurations under windows
and use those settings in the curl
package.
Install the latest version of the curl
package:
install.packages("curl")
stopifnot(packageVersion("curl") >= "0.9.2")
The ie_proxy_info
function looks up your current proxy settings as configured in IE under Internet Options > Tab: Connections > LAN Settings.
ie_proxy_info()
Confirm that the settings correspond to your settings in IE.
The ie_get_proxy_for_url
function determines if and which proxy should be used to connect to a particular URL.
If your settings have an "automatic configuration script" this involves downloading and executing a PAC file, which can take a while.
ie_get_proxy_for_url("http://www.google.com/test")
ie_get_proxy_for_url("http://localhost/test")
ie_get_proxy_for_url("http://foo/test")
The ie_get_proxy_for_url
function either returns a URL of a proxy, or NULL if no proxy should be used for this target host.
Test if you can connect to various servers that you are able to connect to with internet explorer.
connect_with_proxy <- function(url){
proxy_server <- ie_get_proxy_for_url(url)
h <- new_handle(verbose = TRUE, proxy = proxy_server)
readLines(curl(url, handle = h))
}
connect_with_proxy("http://httpbin.org/get")
For completeness, you should include a
library(curl)
call after installation.