Updated to new WebServer-Version
This commit is contained in:
@@ -1,32 +1,21 @@
|
||||
package org.openautonomousconnection.oac2web;
|
||||
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket;
|
||||
import org.openautonomousconnection.webserver.api.Route;
|
||||
import org.openautonomousconnection.webserver.api.WebPage;
|
||||
import org.openautonomousconnection.webserver.api.WebPageContext;
|
||||
import org.openautonomousconnection.webserver.utils.HttpsProxy;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Proxies the HTTPS INS page through OAC.
|
||||
*/
|
||||
@Route(path = "ins.php")
|
||||
public class ins implements WebPage {
|
||||
@Override
|
||||
public WebResponsePacket handle(WebPageContext webPageContext) throws Exception {
|
||||
String content = null;
|
||||
URLConnection connection = null;
|
||||
|
||||
try {
|
||||
connection = new URL("https://open-autonomous-connection.org/ins.php").openConnection();
|
||||
Scanner scanner = new Scanner(connection.getInputStream());
|
||||
scanner.useDelimiter("\\Z");
|
||||
content = scanner.next();
|
||||
scanner.close();
|
||||
}catch ( Exception ex ) {
|
||||
content = ex.getMessage();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return new WebResponsePacket(308, "text/html", new HashMap<>(), content.getBytes(StandardCharsets.UTF_8));
|
||||
@Override
|
||||
public WebResponsePacket handle(WebPageContext webPageContext) {
|
||||
if (webPageContext.request.getPath().equalsIgnoreCase("ins.php"))
|
||||
return HttpsProxy.proxyGet(webPageContext, "https://open-autonomous-connection.org/ins.php");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user