http.get proxy
try this
importPackage(Packages["okhttp3"]);
importClass(java.net.Proxy)
importClass(java.net.Proxy.Type)
importClass(java.net.InetSocketAddress)
let proxyHost = "192.168.10.2";
let proxyPort = 7890;
let userName = "ibozo"
let password = "notapassword"
let client = new OkHttpClient.Builder()
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)))
.build();
var credential = Credentials.basic(userName, password)
let request = new Request.Builder()
.url("https://www.youtube.com")
.header("Proxy-Authorization", credential)
.build();
try {
let response = client.newCall(request).execute()
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
// handle response
let body = response.body().string()
files.create("./body.html")
files.write("./body.html",body)
log("write complete --> ", files.path("./body.html"))
} catch (e) {
log(e)
}