diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 8a86c5d8a..dfc5999e7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -44,9 +44,14 @@ public class ResponseHandler extends TreePageHandler { ServerPageHandler serverPageHandler = new ServerPageHandler(); registerPage("network", serverPageHandler); registerPage("server", serverPageHandler); - if (webServer.isAuthRequired()) { - registerPage("", new RootPageHandler(this)); - } + registerPage("", webServer.isAuthRequired() + ? new RootPageHandler(this) + : new PageHandler() { + @Override + public Response getResponse(Request request, List target) { + return new RedirectResponse("/server"); + } + }); } public void registerWebAPIPages() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java index e29e566a0..86fa225a4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java @@ -1,5 +1,10 @@ package com.djrapitops.plan.system.webserver.response; +import com.djrapitops.plan.system.locale.Locale; +import com.sun.net.httpserver.HttpExchange; + +import java.io.IOException; + /** * @author Rsl1122 * @since 3.5.2 @@ -8,6 +13,12 @@ public class RedirectResponse extends Response { public RedirectResponse(String direct) { super.setHeader("HTTP/1.1 302 Found"); - super.setContent("Location: " + direct); + super.setContent(direct); + } + + @Override + public void send(HttpExchange exchange, Locale locale) throws IOException { + responseHeaders.set("Location", getContent()); + super.send(exchange, locale); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java index bd70b35cb..0456b76ba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java @@ -20,7 +20,7 @@ public abstract class Response { private String header; private String content; - private Headers responseHeaders; + protected Headers responseHeaders; public Response(ResponseType type) { this.type = type.get();