Created
June 22, 2017 23:27
-
-
Save sigmaprojects/6f9e5f979d698dbdde1ff40ad5fb3f01 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private struct function httpRequest(url) { | |
var httpClient = createObject("java","org.apache.http.impl.client.DefaultHttpClient"); | |
var httpGet = createObject("java","org.apache.http.client.methods.HttpGet"); | |
var jURL = createObject("java", "java.net.URL").init(arguments.url); | |
var host = jURL.getHost(); | |
var path = jURL.getPath(); | |
var httpHostTarget = createObject("java","org.apache.http.HttpHost").init(host,80,"http"); | |
var localContext = createObject("java","org.apache.http.protocol.BasicHttpContext"); | |
var httpContent = {} | |
httpContent['fileContent'] = ''; | |
httpContent['statusCode'] = 200; | |
var EntityUtils = createObject("java","org.apache.http.util.EntityUtils"); | |
httpGet.init(toString(arguments.url)); | |
var response = httpClient.execute(httpHostTarget, httpget, localContext); | |
httpContent['fileContent'] = createObject("java","org.apache.http.util.EntityUtils").toString(response.getEntity()); | |
httpContent['statusCode'] = response.getStatusLine().getStatusCode(); | |
httpClient.getConnectionManager().shutdown(); | |
return httpContent; | |
} | |
var foo = httpRequest('http/to/url').fileContent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment