Fix NoSuchElementException ex

This commit is contained in:
DevSnaith 2023-04-14 02:59:36 +03:00
parent a8b4c3eb1f
commit 9b9de358cb
2 changed files with 10 additions and 3 deletions

Binary file not shown.

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.NoSuchElementException;
import java.util.TimeZone; import java.util.TimeZone;
import org.eu.lumiere.loggers.GlobalLogger; import org.eu.lumiere.loggers.GlobalLogger;
@ -13,6 +14,7 @@ import org.eu.lumiere.net.ServerEvents;
import org.eu.lumiere.net.http.HttpRequest; import org.eu.lumiere.net.http.HttpRequest;
import org.eu.lumiere.net.http.HttpRequestHandler; import org.eu.lumiere.net.http.HttpRequestHandler;
import org.eu.lumiere.net.http.HttpResponse; import org.eu.lumiere.net.http.HttpResponse;
import org.eu.lumiere.utils.SimpleResponse;
public class Lumiere implements ServerEvents{ public class Lumiere implements ServerEvents{
@ -50,7 +52,12 @@ public class Lumiere implements ServerEvents{
gmtDate.setTimeZone(TimeZone.getTimeZone("GMT")); gmtDate.setTimeZone(TimeZone.getTimeZone("GMT"));
httpH.setProperty("Date", gmtDate.format(new Date())); httpH.setProperty("Date", gmtDate.format(new Date()));
try {
request.onRequestReceived(new HttpRequest(socket), httpH); request.onRequestReceived(new HttpRequest(socket), httpH);
}catch (NoSuchElementException e) {
httpH.setStatus("HTTP/1.1 400 Bad Request");
new SimpleResponse("Bad Request", false).onRequestReceived(null, httpH);
}
try { try {
if(socket.isConnected()) if(socket.isConnected())