Skip to content

Instantly share code, notes, and snippets.

@at15four2020
Created July 3, 2021 17:14
Show Gist options
  • Save at15four2020/f4a9bc8e466ed98af1a20a940ee6ca95 to your computer and use it in GitHub Desktop.
Save at15four2020/f4a9bc8e466ed98af1a20a940ee6ca95 to your computer and use it in GitHub Desktop.
var http = (function() {
function asResponse(con){
var d = read(con.inputStream);
return d;
}
function read(inputStream){
var inReader = new java.io.BufferedReader(new
java.io.InputStreamReader(inputStream));
var inputLine;
var response = new java.lang.StringBuffer();
while ((inputLine = inReader.readLine()) != null) {
response.append(inputLine);
}
inReader.close();
return response.toString();
}
return function(theUrl, method = "GET"){
var con = new java.net.URL(theUrl).openConnection();
con.requestMethod = method;
return asResponse(con);
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment