From 06f3bf0d426bb73a79071d2eb09ca2074179f20e Mon Sep 17 00:00:00 2001 From: DevSnaith <65865554+DevSnaith@users.noreply.github.com> Date: Thu, 13 Apr 2023 06:27:32 +0300 Subject: [PATCH] Upload project files --- .gitignore | 3 + bin/org/eu/lumiere/Lumiere.class | Bin 0 -> 3892 bytes .../loggers/GlobalLogger$LogLevel.class | Bin 0 -> 1240 bytes bin/org/eu/lumiere/loggers/GlobalLogger.class | Bin 0 -> 2729 bytes bin/org/eu/lumiere/net/ServerEvents.class | Bin 0 -> 170 bytes bin/org/eu/lumiere/net/WebServer.class | Bin 0 -> 3494 bytes .../eu/lumiere/net/http/HttpController.class | Bin 0 -> 3226 bytes bin/org/eu/lumiere/net/http/HttpRequest.class | Bin 0 -> 2816 bytes .../lumiere/net/http/HttpRequestHandler.class | Bin 0 -> 250 bytes .../eu/lumiere/net/http/HttpResponse.class | Bin 0 -> 3646 bytes bin/org/eu/lumiere/utils/BasicResponse.class | Bin 0 -> 1341 bytes src/org/eu/lumiere/Lumiere.java | 71 ++++++++++++++ src/org/eu/lumiere/loggers/GlobalLogger.java | 46 +++++++++ src/org/eu/lumiere/net/ServerEvents.java | 7 ++ src/org/eu/lumiere/net/WebServer.java | 90 ++++++++++++++++++ .../eu/lumiere/net/http/HttpController.java | 43 +++++++++ src/org/eu/lumiere/net/http/HttpRequest.java | 61 ++++++++++++ .../lumiere/net/http/HttpRequestHandler.java | 5 + src/org/eu/lumiere/net/http/HttpResponse.java | 73 ++++++++++++++ src/org/eu/lumiere/utils/BasicResponse.java | 23 +++++ 20 files changed, 422 insertions(+) create mode 100644 .gitignore create mode 100644 bin/org/eu/lumiere/Lumiere.class create mode 100644 bin/org/eu/lumiere/loggers/GlobalLogger$LogLevel.class create mode 100644 bin/org/eu/lumiere/loggers/GlobalLogger.class create mode 100644 bin/org/eu/lumiere/net/ServerEvents.class create mode 100644 bin/org/eu/lumiere/net/WebServer.class create mode 100644 bin/org/eu/lumiere/net/http/HttpController.class create mode 100644 bin/org/eu/lumiere/net/http/HttpRequest.class create mode 100644 bin/org/eu/lumiere/net/http/HttpRequestHandler.class create mode 100644 bin/org/eu/lumiere/net/http/HttpResponse.class create mode 100644 bin/org/eu/lumiere/utils/BasicResponse.class create mode 100644 src/org/eu/lumiere/Lumiere.java create mode 100644 src/org/eu/lumiere/loggers/GlobalLogger.java create mode 100644 src/org/eu/lumiere/net/ServerEvents.java create mode 100644 src/org/eu/lumiere/net/WebServer.java create mode 100644 src/org/eu/lumiere/net/http/HttpController.java create mode 100644 src/org/eu/lumiere/net/http/HttpRequest.java create mode 100644 src/org/eu/lumiere/net/http/HttpRequestHandler.java create mode 100644 src/org/eu/lumiere/net/http/HttpResponse.java create mode 100644 src/org/eu/lumiere/utils/BasicResponse.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a7068f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.settings/* +.project +.classpath diff --git a/bin/org/eu/lumiere/Lumiere.class b/bin/org/eu/lumiere/Lumiere.class new file mode 100644 index 0000000000000000000000000000000000000000..8aede8b5cc68a63acb804f99e1af569729227b9e GIT binary patch literal 3892 zcmb7G`Bxj)75<)t8CgtNWXEf4hAZu_r8Dr=k31( zxDRh?hzK08o#l+IWUNZjl#a~gf>T4AK=%z}&B$0rX*n~qa6=Y64ebKG4H6~kW%ANl zlg{{>EP1Ygumn!#8rUp*d09Gc=3&cTFsz*amKEr5ebFb%w&PK9QlLGc2pn%zp)6gM z3xP4pwy#KIQ91&rT5+y;UO6+tpIPaa?UE}gp*ix&igamd=zT_r(z6nEE# z7~YL1+rrrx()2$BTCzVZNto;Y6y9Y#qs3yqq&?))R2yQFw7#99kb*u39L62 zp;hcPi@6$*^B#39XX_{dw6l*jlTytj4W|YA8giv@*@U(j&I)u*%*|cNoEbioJbU_d za^`Xj_pywgyr~3=Rva1JuTXJLU}PY$=C_kwSe0JAlg)02l+?Vc=7)6LfzB8dQiJx0 z;Q@iptt1CDW$q(79>fK|@4P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s%_w`D{a=8nygsoAE})2fc&XNc75`wfP?J`GioL4IFp)@$_xhG@0f zY&02WtM#M9^;Shcsu~R1hiMt(rLJu`)^L|W%4Az4ZO{G4TcJxTc&3T94so3ut0i-pREB&7@4-u>7kIxPH9rXI-bdRN`6A(PX9@cTWoZWd3RW>gjC30I2}niv}Pa`$>J$7)wSwGDga1N5@DTr&#$$Br~{A{|Z$)k1{cj z2f?b?p&KwcvOq$GR5`b?dWMHLgE4BrWJu_v7CaK#N%>8aubdm^$30?$#Un|_yzXwISKiIQ^U)k7Vt_;(mca! IY?sr20qJcYIRF3v literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/loggers/GlobalLogger.class b/bin/org/eu/lumiere/loggers/GlobalLogger.class new file mode 100644 index 0000000000000000000000000000000000000000..b171720e3b25d9cf900cd23696ae951ad0dae81e GIT binary patch literal 2729 zcmb7GTXR!Y6#jPFwQS}YaxG(Dt&lM5#&(27;@ zf>*rX6~_l>c;TUxnUtaElT&B>CH@Cz#BcAUG@a(5PJ3=^ueJ7C-?#Q!`Rm_1zXNy- z*EF~UcBbuk$jpVTTry$WX2?p%o6;#~F=b`sbfT}KEs@E(p? ziB!TlB2W=*9TlkTPEVRXY($NQO{)SNp2<39Qb#T7sGQC**3I|B9AW^=QTo6Y9d3BM z*dkCr-W+Xe?zuD-P9~d-*;C=B=6=7_3Fy$^_4BP!$9Cup|FDWhEemsIlH5^#wd}N9hGO4o!9~Y>KVUBmL|Hg)N7eZI;L?ap44!d+^v-G8Z{k9@RWc~@7

%?=nzI$s@4F+~Z% zF&$m#7Vz6<#$p`DEKA^E89d4$v{vLrFHci*zZb{lGwMSG&uVx^pnV-@<9=1>h@zjh z6&dIo6xjd&D$3722Xzcd6ueHlkgH7fc^$(T5%6Vm6IoRklKDs}O+{e5;Hea|(&$AU zV>rnskVs9M(}S$=vc;mx=_R?rDRz=zq?}g`FAHo_)H&v~6B+CbOa8S;ij~1if5)wRvK9P)oTBoldwW^XFuX-lpCLu z`;huwMfdkLI?H&Hz@&7fks&a}!V%~xjjVghu!qg_IWrYAOAq-fc^TJU*gT)iU+&@P z$l(HMWHEQmI3^oSB~MA0AJceM!wl=XT+h~V39kvbFWL!*weJp&ceRen{`$I(H&iDz zZQGB_cw56;0(HwiN*bz;ckr%k{j#lDZ2hZPU&eS;!+Rz6k-^^Sn3-`BX&MNEDU!UH zPwCt!+A8Ks zk7f>=3eN5d&Kr&_zWL->;&YpvKzvs6YXfxZRq^WxT)YDf^QgXs`r3wD*t!TYwt#K7 zu;V6ITzHW8YUR~Wj~kSAlUk9h9CbxsAwC7=?!60WUNQA3VHKo_RHXtQQlVVNPVAzD zfr!89+Q+q}dDJhVx_t@$_B?i9gL~hctHZsBma%zkT|isd6Y$jTzm13U=x`s%Bb>)k zCF`Mn;jORjPx$8X^mSCWz8{s8Ee3kM>da(*HIPL<}n-4 z@_2LK9J9KC1>C_E0w)3NLk;isyl+Mw8u+(`C~QRs0ys)?PM{Gd31$pCVB-PI(&}f* zZcuB1INc>ue_)S7@r*)msfZ#m!~5u0$S&an(km%l!iV@sk+y`7ah0?;U=E+)Q-%Jo z_>6iU?$(LV`KEEdX11v>_a*n@ z70a$uk?Q=9`2RuoxP~h}vivQ+E3mHEr!6Yyv15+ULa`MprcLE4b8+E&b^ifB@+p5} KMR@&mH1HpIXPR07 literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/net/ServerEvents.class b/bin/org/eu/lumiere/net/ServerEvents.class new file mode 100644 index 0000000000000000000000000000000000000000..86889605dbc3067ff120d0659eb499a9c34a9dc5 GIT binary patch literal 170 zcmYk0y$ZrG6ot>N+Nd}vxV!3N7B@%HNpL8**K#SX@djd&hjZ`&d?+#PvQkvl9-*2vjX<>t__|zCCEdG19ojoTI2I&nzX=a4HBdDYq#y>dTETsSd literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/net/WebServer.class b/bin/org/eu/lumiere/net/WebServer.class new file mode 100644 index 0000000000000000000000000000000000000000..c21063f6da9e05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7f6W76&ZUp46pOt>QXdZBBK8wlX|7BL(uT|3TVspyZ?3w+FS1& zv>;eNB#;sa?&8_|*e637*H_V91F?*c)_@amCUAj`oizL%F0v7_)hFHfzQ^T$8T=+yaTIE!teVY!F z6rXG&#ivP%R2eUn@%ct>tYS$5lENtCORKmXhWC=hHh3THG7SD6UyFdVs@bkrNHfyq z+hu&OiEIA}7HTsEVvY>@@$L1O8q9H8rS9uZ=I)RnN90lj3MPt1nuDri)xe- zg5wzF#wqm_-?Bt?f;pI^&J^#H^LT}FuVV&(CDwwlK|8?P6@*3q=lBHyeV$l9SHpT2 zT935<6WtnKT_=B~T;*|V`&LeP2k|NWCoRhyTNq06*PKLxX3`og&IRY`p+M!l2!0tz R{R$#2O=FlJO}{z4>)$-FP7MG6 literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/net/http/HttpController.class b/bin/org/eu/lumiere/net/http/HttpController.class new file mode 100644 index 0000000000000000000000000000000000000000..c8b9223ecf825879acb558cd77e51ca4cdb4ab6e GIT binary patch literal 3226 zcmbtWdvg<296g()-85Z}k@85>LIhuE09&fiN@%g6t+b+U(@VOr?1s&zTHg=A z_xmx!ci<0oB!G+#|2g9a@l!aC=k9JFNp=9oVb~@&zkBXE=l&l1=Rd#x4&YJzpdzAR zm+cfYqLMKy7YyNuj3wO6yz7=S!+Z?cmh0H2DI66s1?$e~3wp-Xtzu?u_M9lVDw-9f z?}jigE>=X@9oDTmq9{;I1v_(fJ50M+6izvF%(Q29Gv|HFDu~bfyUGeWa^BGu*Dy1~ zdU^hYUSdE?-Y8nSTXBSfd}G8xf63#UcOAnjX6sL`QCrJ3dzdFQA2ck(J**&_>YY>& z8?xs_0#USSSc3-==s=f>P6a*pp-97eY#`~PaD9micBgvl8HIY$0tK5isEDiBte~yI zj0C#TCZo1#XhA~3+MHpD(aMEc;hfTEO&ZjmvkSU8sXK=J9xTS(d4u+*>RHtIvXTXK zB%#mEE#Kx~>i=2XJKcg^NU7MZp#MHB+(F}VVnL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mV?d00001 diff --git a/bin/org/eu/lumiere/net/http/HttpRequest.class b/bin/org/eu/lumiere/net/http/HttpRequest.class new file mode 100644 index 0000000000000000000000000000000000000000..50569633f91f960f92bc41461eb5c9d22d3c02ca GIT binary patch literal 2816 zcmbVNTXz#x6#h<{WYTni-rHD&D$u5BOAt_?rCcpgNh!9_TDj;nJxzyBlQ5Ye#k=AS zygc{=)F)omC8^pa%Qx5Z(Vydk_??+ao3?pCU*??IXYX&{_x|&rUmpQDh_5sR1a{@@ zOi~t;R&mjkwoGQFlbm;)eDWMWTp5liC1a zBwR+`mDAT3g;6mCk%_R-iGphBe{XW;R0xjSLqJXI>!6+aw{(T$Vq1 zJC~QXW6FX+t0!1=Oe=YDl}_RCQ8Q~g#{`<=9*c5gB9~r}&S1}^K=5>KRz^{S1|3__ zC{PpcnT((-H<`zU&`U#U7E(BiAAd{>$3#q&B|P-wMTdE0UIsIVT^p&_Df13GHG z+ff}+L^P;!aGl#wFHsDkL5ZByQ3pMO(=6qID28!X!9zG>Ev7K7;T3_tCur^6Y=)G)B`qDV;tGQ_JU%`)F0l7WI%8Fs^?D7j zX}Hc}E7#-5*zoPN%sU(dI$l?)kFxqlWuahX*vrkB(UAtnNjT3D;>-yw#s8bq%@MAk z_|d3Lt52#-gHK|^ssg`IT%3{iC1b{7tv9A}X~UW{Y*YRF#Go^8a*%DBn$^axnrmsx zlvx%?gJ;>=Kv0hbcXSAJc#rG*+wWAesrHjL=fEo4`c@~Dpb8(QS~rs;Xt@pCR2dJy ze<@CPTUOC45=X%;6ONHy7&Y>K1T-e`yj)@sTH@83Ms??sjyrghrZ32)38~yK&kfHy zPW3vxjdwM?Lj`L+PF@}F;eBosCwJ1e4fa7iUTJbUg;i)87^6B`x7I^lRob#L`>O+N z2p{YC5O>+`G}+q{DTpQ(_CY^1BTXUsFmW_1nZU>JvYs z=^U-xiUj z-hNKD9O*$KcH<`F8p2)Dy_-SwbFdlV`?RG1hq6T?CJ}s00j_+ZVTXne4P6>~H7)`C zjjqQ`OTc?m4A+{e{1)EemkGi#f^cJ?S%t2I+YHF?FL*0}-|@lsqzBw!sHB3cQ8}c0 z{Juj%6{C+eMD74NY84hU{Lw~$qzlmMF|9_VmNAPELf}*E^P!UNKkJTAhc?0-sIVin rYR6|)g^z3$K2%lsURB}2jlzRfgab^6iqq%#f@hS5Pcc1To{0Sm)Z?$} literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/net/http/HttpRequestHandler.class b/bin/org/eu/lumiere/net/http/HttpRequestHandler.class new file mode 100644 index 0000000000000000000000000000000000000000..071e01f4d2d689d233f0125fd2ec08275fab60e5 GIT binary patch literal 250 zcma)%Jr06E6olvD4{D{AS5OPLv7MiWfz5nd3o?&7k`;Ve9WhcYgSorN}&DZWg; zdA{xs02_=$1ca3~gkIRWl+u zeI!lV=Fyfu@+Rr~;Xd*q$%+L@R=e`4S*xG>d+P3cXJikOXz5zE=FYw6?t9KY`<^rZ z{P#zH2XFxIXb1@m*wtdrtmR6zCCjXuxw7fz7G1ZJJISB(rc<%Yj;SFcu=R>@&B&FE zaxphGf5j}g0-_`^IMIYqvWrEt>f|0N+4DweLcNU&Y<673tvQ!UR@oHjp4dRkyH%@P zq={az%dS~=FS*MV+C-%vivss~wl&u(=3S$3m1kggWDL<`Eqyaf-4tDiyQ5 zKpul=4Yyj*e1}FQ#AzK9m=uV)wr4NUL#Z^!KwE(+9cOXQ)75EnId95a&@fgRX%f1TN-pS_!37>@t4u?g!fSTb zr!R&}^l{Kh98L^6k|+T~$2Wq_mYoZ(D9wPnJ*X43I*<2%GSe*XN_d4X*6g=<&g*EchWXYj0s@3L?=96dF4{CdHxxRzbk z@tl-roY761j$;&A8n@&7I(~rXnT`rufy-;Ooc#X|4P?qsd|<}U-Tz3ZZ$-N2?FFhS zIxp|JKz{(q!*1L+*1M}FEd>eh^{kkcK(H)Ao1LIShuWyD1%6bvhb(@kbp2` z%xlrpszZn5M}X`~4YMwe0~XS)U+ee{eoMEw)O1Dvn-hbLJJP5_Z5sL*wU)&nbo^0P zu@2^fWr<~K-67dmsI|OZs}{@?mh3Fsg5Nb+DNufQoGO>i>amjHIP$v18utJXvebn6 zu@pr}c2JH&vQ?@lJEMBC&(TU(<4&%#qj4;Y)K+ZcZ#N*e6D7jgne;8(m%fd@RotKM z-noiIx_j3u2GYZyBA)&L11pFO^F8wqY{}HI=O$w5jI`of=2LWjjO^?!>|22*CsvV3 z?_I_I_lO+EL;OwiT%d<%b<(RYp1*~ctC#hz4Nruyqa04A>p1fvSe6b)R*>wEe2B*dKEcqL zO!wEKe?xdSJe;46q=)PHdj2*RxbcECVvoPM_Af&2uj6V)0q*rc>#*x^REwl7O6o@AItI;X6QO6G`B$_E-bWSR=%G=q^}q z`&hrgq)$aoVe{TH{=~cMZgp@Pl)99@uEtT{C4pbI-8|5|`Ec9K{1)*~KFUZXBf6i2 zUs0LO7-NAr^mR^jpK>9;$%x@ql;6qv!MiKD0;>U2TgUI45yt~w#nwYwX&X`tA14Bv a8+?TDCmt8VpYazyWifk-<>RkM`~L$VpFWWQ literal 0 HcmV?d00001 diff --git a/bin/org/eu/lumiere/utils/BasicResponse.class b/bin/org/eu/lumiere/utils/BasicResponse.class new file mode 100644 index 0000000000000000000000000000000000000000..31460a0c3bf8d78364d6ffac3805aceef9e7a734 GIT binary patch literal 1341 zcmah}TTc@~6#k~$c1v9fv=mY9m(mN!dRHuBB8lMvF`=Z1_+Yl}NEh4Px;sncr}%Ed zvqsRE=&Ol8N<6dM0IiL5yR&D{nfc~B-#N3t|9t-m;4aowgcxRRXHVyz-td|xcew5e zv*GGb4cDx0bGKz%E>{s|7~D4w4837kd-{vYKCcQDQHDa-YKsfKE<{V;pkbT8^SCQE z46D}Q4nw$N*A5wyo99p^;h5H5k)gjXnvK^^dq)Pg%Me{PEmN#9jO6}ZvYRgx;<{bq zaVQwja0P=5N-kfHA;~b>k-@a-PCK4u(O!LE7}lU7Can<-eTXv*Y?>C|@|qRy>==~> zmn`k7(I^{^Dc{@9u&A3Z!~AAf+C4<0oFa})igGInqx$x_(ehDLOm?UlNWd^;TW!I% zd6k<7yvDGV>)xrCz{N`@1yw9cWo8*v!QTr#58TGnG(SCaSNPdN$nZj2j3dx~k zqzcM0(uKueh!?&fb%gMubdHnr6HQcbmB#Cc(x@TqgT^sHU{gq7o~%)dOb4L2Ml%HAXZ-7$-Z6&?&~Cs9-84=+KgJO8zrPD2Nc(DS`|bf2OS^ { + httpH.setProperty(key, header.getProperty(key)); + }); + + request.onRequestReceived(new HttpRequest(socket), httpH); + try { + if(socket.isConnected()) + socket.close(); + }catch(IOException ex) { + l.printf(LogLevel.ERROR, ex.getMessage(), null); + } + } + + public void bootServer(int port) { + if(server != null) { + l.printf(LogLevel.ERROR, "Lumiere is already running", null); + return; + } + + server_port = port; + server = new WebServer(this.getClass().getSimpleName(), this, server_port); + server.start(); + } + + public HttpResponse getSharedResponseHeader() { + return header; + } + + public int getCurrentPort() { + return server_port; + } +} diff --git a/src/org/eu/lumiere/loggers/GlobalLogger.java b/src/org/eu/lumiere/loggers/GlobalLogger.java new file mode 100644 index 0000000..3ff1595 --- /dev/null +++ b/src/org/eu/lumiere/loggers/GlobalLogger.java @@ -0,0 +1,46 @@ +package org.eu.lumiere.loggers; + +import java.io.IOException; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class GlobalLogger { + + public static OutputStream os = System.out; + public static String pattern = "[!L !D{h:mm a}]: !M\n"; + private static final GlobalLogger logger = new GlobalLogger(); + private GlobalLogger() {} + + public static enum LogLevel { + INFO, WARNING, ERROR; + } + + public Object printf(LogLevel l, String m, Object r, Object... args) { + if(os == null || (m == null || m.length() <=0)) + return r; + int index = -1; + String output = new String(pattern); + output = output.replaceAll("!CNAME", Thread.currentThread().getStackTrace()[2].getClassName()); + output = output.replaceAll("!M", m); + output = output.replaceAll("!L", (l == null ? LogLevel.INFO : l).toString()); + while((index = output.indexOf("!D{")) != -1) { + String dPattern = output.substring(index); + dPattern = dPattern.substring(3, dPattern.indexOf("}")); + SimpleDateFormat format = new SimpleDateFormat(dPattern); + output = output.replace(String.format("!D{%s}", dPattern), format.format(new Date())); + } + try { + os.write(output.getBytes()); + } catch (IOException e) { + System.err.println(e); + } + + return r; + } + + public static GlobalLogger getLogger() { + return GlobalLogger.logger; + } + +} diff --git a/src/org/eu/lumiere/net/ServerEvents.java b/src/org/eu/lumiere/net/ServerEvents.java new file mode 100644 index 0000000..26e38b3 --- /dev/null +++ b/src/org/eu/lumiere/net/ServerEvents.java @@ -0,0 +1,7 @@ +package org.eu.lumiere.net; + +import java.net.Socket; + +public interface ServerEvents { + public void onConnection(Socket socket); +} diff --git a/src/org/eu/lumiere/net/WebServer.java b/src/org/eu/lumiere/net/WebServer.java new file mode 100644 index 0000000..f33d447 --- /dev/null +++ b/src/org/eu/lumiere/net/WebServer.java @@ -0,0 +1,90 @@ +package org.eu.lumiere.net; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; + +import org.eu.lumiere.loggers.GlobalLogger; +import org.eu.lumiere.loggers.GlobalLogger.LogLevel; + +public class WebServer implements Runnable { + + private GlobalLogger l = GlobalLogger.getLogger(); + private String threadName = "Lumiere server thread"; + private boolean isRunning = false; + private Thread thread; + + private int port = 8080; + private ServerSocket server; + private ServerEvents e; + + public WebServer(String name, ServerEvents e, int port) { + this.threadName = name == null ? this.threadName : name; + this.port = port; + this.e = e; + } + + public synchronized void start() { + if(isRunning || thread != null) { + l.printf(LogLevel.WARNING, threadName + " is already running", null); + return; + } + + try { + server = new ServerSocket(port); + } catch (Exception ex) { + l.printf(LogLevel.ERROR, ex instanceof IllegalArgumentException ? + "Server port must be between 0 and 65535" : ex.getMessage(), null); + } + + thread = new Thread(this, threadName); + isRunning = true; + thread.start(); + } + + public synchronized void stop() { + if(!isRunning || thread == null) { + l.printf(LogLevel.WARNING, threadName + " is already running", null); + return; + } + + thread.interrupt(); + isRunning = false; + thread = null; + + if(server != null) { + try { + server.close(); + } catch (IOException e) { + l.printf(LogLevel.ERROR, e.getMessage(), null); + } + } + } + + @Override + public void run() { + l.printf(LogLevel.INFO, threadName + " using port " + getPort(), null); + while(isRunning && !thread.isInterrupted()) { + try { + + if(server == null) { + stop(); + continue; + } + + Socket s = server.accept(); + if(e != null) + e.onConnection(s); + l.printf(LogLevel.INFO, "New Connection " + s.getInetAddress().getHostAddress(), null); + } catch (IOException ex) { + l.printf(LogLevel.ERROR, ex.getMessage(), null); + } + } + l.printf(LogLevel.INFO, threadName + " has been stopped", null); + } + + public int getPort() { + return this.port; + } + +} diff --git a/src/org/eu/lumiere/net/http/HttpController.java b/src/org/eu/lumiere/net/http/HttpController.java new file mode 100644 index 0000000..e62e570 --- /dev/null +++ b/src/org/eu/lumiere/net/http/HttpController.java @@ -0,0 +1,43 @@ +package org.eu.lumiere.net.http; + +import java.util.HashMap; + +import org.eu.lumiere.loggers.GlobalLogger; +import org.eu.lumiere.loggers.GlobalLogger.LogLevel; + +public class HttpController implements HttpRequestHandler { + + private GlobalLogger l = GlobalLogger.getLogger(); + private HashMap handlers = new HashMap<>();; + + public boolean addHandler(String path, HttpRequestHandler handler) { + if(handler == null) + return (boolean) l.printf(LogLevel.WARNING, "The handler ["+path+"] is null", false); + + if(handler.equals(this)) + return (boolean) l.printf(LogLevel.WARNING, "The handler cannot be the HttpController", false); + l.printf(LogLevel.INFO, "A Handler for " + path + " has been created", null); + handlers.put(path, handler); + return true; + } + + @Override + public void onRequestReceived(HttpRequest request, HttpResponse response) { + String clientUrl = request.getURL(); + if(handlers.containsKey(clientUrl)) + handlers.get(clientUrl).onRequestReceived(request, response); + } + + public HttpRequestHandler getHandler(String path) { + return handlers.get(path); + } + + public HttpRequestHandler[] getHandlers() { + return handlers.values().toArray(new HttpRequestHandler[0]); + } + + public String[] getPaths() { + return handlers.keySet().toArray(new String[0]); + } + +} diff --git a/src/org/eu/lumiere/net/http/HttpRequest.java b/src/org/eu/lumiere/net/http/HttpRequest.java new file mode 100644 index 0000000..0a5f99d --- /dev/null +++ b/src/org/eu/lumiere/net/http/HttpRequest.java @@ -0,0 +1,61 @@ +package org.eu.lumiere.net.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.Socket; +import java.util.Properties; +import java.util.StringTokenizer; + +import org.eu.lumiere.loggers.GlobalLogger; +import org.eu.lumiere.loggers.GlobalLogger.LogLevel; + +public class HttpRequest { + private GlobalLogger l = GlobalLogger.getLogger(); + private String reqMethod, reqPath, reqVersion; + private Properties properties; + public HttpRequest(Socket client) { + try { + InputStreamReader stream = new InputStreamReader(client.getInputStream()); + BufferedReader reader = new BufferedReader(stream); + StringTokenizer t = new StringTokenizer(reader.readLine()); + reqMethod = t.nextToken(); + reqPath = t.nextToken(); + reqVersion = t.nextToken(); + + String line; + properties = new Properties(); + while((line = reader.readLine()) != null) { + String[] split; + if((split = line.split(":", 2)).length >= 2) { + properties.setProperty(split[0], split[1].replaceFirst ("^ *", "")); + }else { + break; + } + } + + } catch (IOException e) { + l.printf(LogLevel.ERROR, e.getMessage(), null); + } + } + + public String[] getKeys() { + return properties.keySet().toArray(new String[0]); + } + + public String getProperty(String key) { + return properties.getProperty(key); + } + + public String getMethod() { + return reqMethod; + } + + public String getURL() { + return reqPath; + } + + public String getHttpVersion() { + return reqVersion; + } +} diff --git a/src/org/eu/lumiere/net/http/HttpRequestHandler.java b/src/org/eu/lumiere/net/http/HttpRequestHandler.java new file mode 100644 index 0000000..d49d86d --- /dev/null +++ b/src/org/eu/lumiere/net/http/HttpRequestHandler.java @@ -0,0 +1,5 @@ +package org.eu.lumiere.net.http; + +public interface HttpRequestHandler{ + public void onRequestReceived(HttpRequest request, HttpResponse response); +} diff --git a/src/org/eu/lumiere/net/http/HttpResponse.java b/src/org/eu/lumiere/net/http/HttpResponse.java new file mode 100644 index 0000000..c1ffd6f --- /dev/null +++ b/src/org/eu/lumiere/net/http/HttpResponse.java @@ -0,0 +1,73 @@ +package org.eu.lumiere.net.http; + +import java.io.IOException; +import java.net.Socket; +import java.util.HashMap; +import java.util.Set; + +import org.eu.lumiere.loggers.GlobalLogger; +import org.eu.lumiere.loggers.GlobalLogger.LogLevel; + +public class HttpResponse { + + private GlobalLogger l = GlobalLogger.getLogger(); + private String status_line = "HTTP/1.0 200 OK"; + private String content_type = "text/html"; + + private HashMap httph; + private Socket client; + + public HttpResponse(Socket client, String status_line, String content_type) { + this.content_type = content_type == null ? this.content_type : content_type; + if(status_line != null && !status_line.isEmpty()) + this.status_line = status_line; + httph = httph == null ? new HashMap<>() : httph; + this.client = client; + } + + public void push(String body) { + try { + StringBuilder build = new StringBuilder(status_line+"\r\n"); + for(String key : getKeySet()) { + build.append(String.format("%s : %s\r\n", key, getProperty(key))); + } + client.getOutputStream().write(build.append("\r\n").append(body).toString().getBytes()); + } catch (IOException e) { + l.printf(LogLevel.ERROR, e.getMessage(), null); + } + } + + public void setProperty(String key, String value) { + if(!httph.containsKey(key)) + httph.put(key, value); + } + + public void setStatus(String sl) { + this.status_line = sl; + } + + public void setContentType(String ct) { + this.content_type = ct; + } + + public String getStatus() { + return this.status_line; + } + + public String getContentType() { + return this.content_type; + } + + public String getProperty(String key) { + return httph.get(key); + } + + public Set getKeySet() { + return httph.keySet(); + } + + public String getStatusLine() { + return status_line; + } + +} diff --git a/src/org/eu/lumiere/utils/BasicResponse.java b/src/org/eu/lumiere/utils/BasicResponse.java new file mode 100644 index 0000000..2522e9a --- /dev/null +++ b/src/org/eu/lumiere/utils/BasicResponse.java @@ -0,0 +1,23 @@ +package org.eu.lumiere.utils; + +import org.eu.lumiere.net.http.HttpRequest; +import org.eu.lumiere.net.http.HttpRequestHandler; +import org.eu.lumiere.net.http.HttpResponse; + +public class BasicResponse implements HttpRequestHandler { + + private String body = "BasicResponse is running"; + private boolean html_response = false; + + public BasicResponse(String body, boolean rhtml) { + this.body = body == null ? this.body : body; + this.html_response = rhtml; + } + + @Override + public void onRequestReceived(HttpRequest request, HttpResponse response) { + response.setContentType(String.format("text/%s", html_response ? "html" : "plan")); + response.push(body); + } + +}