Skip to content

Instantly share code, notes, and snippets.

@idarlington
Last active July 5, 2018 12:04
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 idarlington/0776335c3807fd6069797a36874db583 to your computer and use it in GitHub Desktop.
Save idarlington/0776335c3807fd6069797a36874db583 to your computer and use it in GitHub Desktop.
create a groovy connection
class Connection {
String urlPath
private String username = project.properties.username
private String password = project.properties.password
private String basicAuth = "$username:$password".bytes.encodeBase64().toString()
URL url = urlPath.toURL();
InputStream getStream() {
URLConnection connection = url.openConnection();
connection.setRequestProperty("Authorization","Basic $basicAuth");
InputStream inputStream = connection.getInputStream();
return getStream()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment