From 9b9de358cb0c691d72116192e598441169e6e15c Mon Sep 17 00:00:00 2001 From: DevSnaith <65865554+DevSnaith@users.noreply.github.com> Date: Fri, 14 Apr 2023 02:59:36 +0300 Subject: [PATCH] Fix NoSuchElementException ex --- bin/org/eu/lumiere/Lumiere.class | Bin 4371 -> 4661 bytes src/org/eu/lumiere/Lumiere.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/org/eu/lumiere/Lumiere.class b/bin/org/eu/lumiere/Lumiere.class index 659cca70e13a9a9b077d5049f2ba50a92440face..fd0a09c07d018a0b6565cdaadc11c99798092539 100644 GIT binary patch delta 1257 zcmaKqX-pht7{`CZ0<$|izzXS7Xxc@fT9(?OhgAzAQn4i#Xjp=2zisIR7WSyjtTFKe zi6$m^U}3bio>g00Z>ily!M4_;YCYNz3#yuHgSyy)hh} zGq^<|xMag%bmYpY5sxPOjfg!QOZGQzuItqp<2sF<>{7W+p=2;BIZ4wtBB{P1)7H72 zJEUsNTANBH%|6@Qs^D2tx7mfv6Ru?)pk{%xy_EH zk~;SjS*f7)n|6n3Sv{uxrlD|B=T%-SQTZa^PF-&olZSIOOd0$sg~iS< z{&MGpzu2Slo%54^YVktynI{^{DP<802yqToETfucYG|jH9zp$9)a*-BAV2JPT8alo z_EEVee`)DxmK$am+f=&UGsT3mG|R2^S$6E=OxfN@BlRx`C0B!JcsaPslR-Z zJbD>mh&@~*Z*;qi+ry<&zLkKiVN~kz3Yn0QS;0!09Ohl#lilt7shoYzmwd(7a#AWe-|#Kp Mi@sXs^FvF;pJpX08~^|S delta 976 zcmZXSU2GIp6vuzJv)$QFXSW}#g|@US?N(r0*dU;#Vgr&cG>9bBK;+3ynUvCYw_%p1 z2@ehN$qEI$prU+KsNxq$kq%e{tO6?d{Q>%7eCNdnpVc!X#s@OVx%Zwq|MUO<@3~V+ z-C*7PYx)YXlwT*U6_F8(QTCX;s3_Z>9m=M2P9fcu@9uL7HhURUl=ix-^SPYUU2wK4 zjQI<;_>lcJ2dGjMclYOA$3k<+on7Oj-J4H=fD0QB?b2L_mJYG`9Wektz&66T;8!kgK z1%r%$A0;YrJ|+u@&`g3B9$_&nBzCZbO)L{cD|wa+u8mkGc7)8=%Bd_tgkPVBYBODcX>!h*~PyBBwRXar@mAS;kvnh|aJl;)7RpJ64Ofl}mJkCu@i+}yri&I!B zaTV1(DMC6#Zbt55jksE?V->R=n8F{UFVjHP$kyY6US5%`UKiN5C4=0&ZyVWPS-SK~j}c^dmoWM;s=Z%`Ypf{{d&t%-a9} diff --git a/src/org/eu/lumiere/Lumiere.java b/src/org/eu/lumiere/Lumiere.java index 0f42dd2..989af10 100644 --- a/src/org/eu/lumiere/Lumiere.java +++ b/src/org/eu/lumiere/Lumiere.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.Socket; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.NoSuchElementException; import java.util.TimeZone; 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.HttpRequestHandler; import org.eu.lumiere.net.http.HttpResponse; +import org.eu.lumiere.utils.SimpleResponse; public class Lumiere implements ServerEvents{ @@ -49,9 +51,14 @@ public class Lumiere implements ServerEvents{ SimpleDateFormat gmtDate = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); gmtDate.setTimeZone(TimeZone.getTimeZone("GMT")); httpH.setProperty("Date", gmtDate.format(new Date())); - - request.onRequestReceived(new HttpRequest(socket), httpH); - + + try { + 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 { if(socket.isConnected()) socket.close();