Probably should use TFTP actually
This commit is contained in:
parent
4c4301d2d9
commit
897372f098
3 changed files with 39 additions and 1 deletions
|
@ -111,6 +111,9 @@ public class ButtonWebsiteModule extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
addPage(new IndexPage());
|
||||
addPage(new AutoUpdatePage());
|
||||
addPage(new LoginPage());
|
||||
addPage(new ProfilePage());
|
||||
TBMCCoreAPI.RegisterUserClass(WebUser.class);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||
this.getLogger().info("Starting webserver...");
|
||||
|
|
35
src/buttondevteam/website/page/AutoUpdatePage.java
Normal file
35
src/buttondevteam/website/page/AutoUpdatePage.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package buttondevteam.website.page;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
import buttondevteam.website.io.IOHelper;
|
||||
import buttondevteam.website.io.Response;
|
||||
|
||||
public class AutoUpdatePage extends Page {
|
||||
|
||||
@Override
|
||||
public String GetName() {
|
||||
return "autoupdate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response handlePage(HttpExchange exchange) {
|
||||
if (exchange.getRequestHeaders().containsKey("Expect")
|
||||
&& exchange.getRequestHeaders().get("Expect").contains("100-continue"))
|
||||
try {
|
||||
exchange.sendResponseHeaders(100, -1);
|
||||
exchange.getResponseBody().close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return new Response(200,
|
||||
"Headers:\n" + exchange.getRequestHeaders().entrySet().stream()
|
||||
.map(e -> e.getKey() + ": " + e.getValue().stream().collect(Collectors.joining(" ")))
|
||||
.collect(Collectors.joining("\n")) + "\nPOST: " + IOHelper.GetPOST(exchange),
|
||||
exchange);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,7 +22,7 @@ public abstract class Page implements HttpHandler {
|
|||
if (exchange.getRequestURI().getPath().equals("/" + GetName()))
|
||||
IOHelper.SendResponse(handlePage(exchange));
|
||||
else {
|
||||
IOHelper.SendResponse(404, "404 Not found", exchange);
|
||||
IOHelper.SendResponse(404, "404 Not found: " + exchange.getRequestURI().getPath(), exchange);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Internal Server Error in ButtonWebsiteModule!", e);
|
||||
|
|
Loading…
Reference in a new issue