Last active
July 5, 2018 12:04
-
-
Save idarlington/0776335c3807fd6069797a36874db583 to your computer and use it in GitHub Desktop.
create a groovy connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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