Skip to content

Instantly share code, notes, and snippets.

@tom1299
Created May 3, 2018 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom1299/133845d5194779f789852054fab774ef to your computer and use it in GitHub Desktop.
Save tom1299/133845d5194779f789852054fab774ef to your computer and use it in GitHub Desktop.
Open url in groovy using a http proxy
setProxies("http");
setProxies("https");
println 'http://www.google.com'.toURL().text
def setProxies(String protocol) {
String port = new URI(System.getenv("${protocol}_proxy")).port
String host = new URI(System.getenv("${protocol}_proxy")).host
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment