Created
July 3, 2021 17:14
-
-
Save at15four2020/f4a9bc8e466ed98af1a20a940ee6ca95 to your computer and use it in GitHub Desktop.
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
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