diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 74ac1a759..bca3ef3b7 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -86,7 +86,7 @@ public class RequestHandler implements HttpHandler { try { Response response = responseHandler.getResponse(request); if (response instanceof PromptAuthorizationResponse) { - responseHeaders.set("WWW-Authenticate", "Basic realm=\"/\""); + responseHeaders.set("WWW-Authenticate", response.getHeader("WWW-Authenticate").orElse("Basic realm=\"Plan WebUser (/plan register)\";")); } response.setResponseHeaders(responseHeaders); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java index ede1b373b..177a94dc6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java @@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Objects; +import java.util.Optional; import java.util.zip.GZIPOutputStream; /** @@ -53,6 +54,15 @@ public abstract class Response { return header; } + public Optional getHeader(String called) { + for (String header : header.split("\r\n")) { + if (header.startsWith(called)) { + return Optional.of(header.split(": ")[1]); + } + } + return Optional.empty(); + } + public void setHeader(String header) { this.header = header; }