mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Fixed authentication message showing '/'
This commit is contained in:
parent
6806e6c98e
commit
75782562f9
@ -86,7 +86,7 @@ public class RequestHandler implements HttpHandler {
|
|||||||
try {
|
try {
|
||||||
Response response = responseHandler.getResponse(request);
|
Response response = responseHandler.getResponse(request);
|
||||||
if (response instanceof PromptAuthorizationResponse) {
|
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);
|
response.setResponseHeaders(responseHeaders);
|
||||||
|
@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +54,15 @@ public abstract class Response {
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<String> 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) {
|
public void setHeader(String header) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user