* improved page reqest handling
This commit is contained in:
parent
67694ba6e0
commit
0f33a475a4
@ -35,7 +35,7 @@ public class MainPage implements HttpHandler {
|
|||||||
Log.debug("looking for: " + path);
|
Log.debug("looking for: " + path);
|
||||||
|
|
||||||
if (path.contains(".html")) {
|
if (path.contains(".html")) {
|
||||||
if (LoginState.getObject().isLoggedIn() || path.equals("/register.html")) { //pass only register page
|
if (LoginState.getObject().isLoggedIn() || path.equals("/register.html") || path.equals("/index.html")) { //pass only register page
|
||||||
sendPage(path, t);
|
sendPage(path, t);
|
||||||
} else {
|
} else {
|
||||||
Log.warning("user not logged in --> redirecting to login page");
|
Log.warning("user not logged in --> redirecting to login page");
|
||||||
@ -49,11 +49,11 @@ public class MainPage implements HttpHandler {
|
|||||||
private void sendPage(String path, HttpExchange t) throws IOException {
|
private void sendPage(String path, HttpExchange t) throws IOException {
|
||||||
InputStream fs = getClass().getResourceAsStream("/wwwroot" + path);
|
InputStream fs = getClass().getResourceAsStream("/wwwroot" + path);
|
||||||
|
|
||||||
if (fs == null && path.substring(path.length() - 4).equals("html")) {
|
if (fs == null && path.contains(".html")) {
|
||||||
Log.warning("wrong page sending 404");
|
Log.warning("wrong page sending 404");
|
||||||
sendPage("/404Error.html", t);
|
sendPage("/404Error.html", t);
|
||||||
} else if (fs == null) {
|
} else if (fs == null) {
|
||||||
|
Log.warning("requested resource doesnt exist");
|
||||||
} else {
|
} else {
|
||||||
// Object exists and is a file: accept with response code 200.
|
// Object exists and is a file: accept with response code 200.
|
||||||
String mime = "text/html";
|
String mime = "text/html";
|
||||||
|
Loading…
Reference in New Issue
Block a user