Added conditions for some robustness

This commit is contained in:
Ziver Koc 2015-12-11 23:53:24 +01:00
parent 930ad2b2f3
commit 31c700b738
3 changed files with 4 additions and 2 deletions

BIN
Zutil.jar

Binary file not shown.

4
src/zutil/net/http/HttpServer.java Normal file → Executable file
View file

@ -231,7 +231,7 @@ public class HttpServer extends ThreadedTCPNetworkServer{
out.setHeader( "Content-Type", "text/html" );
out.setCookie( "session_id", ""+client_session.get("session_id") );
if( !parser.getRequestURL().isEmpty() && pages.containsKey(parser.getRequestURL()) ){
if( parser.getRequestURL() != null && !parser.getRequestURL().isEmpty() && pages.containsKey(parser.getRequestURL()) ){
pages.get(parser.getRequestURL()).respond(out, parser, client_session, cookie, request);
logRequest(parser, client_session, cookie, request, time);
}
@ -247,7 +247,7 @@ public class HttpServer extends ThreadedTCPNetworkServer{
//********************************************************************************
} catch (Exception e) {
logger.log(Level.WARNING, "500 Internal Server Error", e);
logger.log(Level.SEVERE, "500 Internal Server Error", e);
try {
if (!out.isHeaderSent())
out.setStatusCode(500);

View file

@ -101,6 +101,8 @@ public class Templator {
* be regenerated if the file changes.
*/
public Templator(File tmpl) throws IOException {
if(tmpl == null)
throw new IllegalArgumentException("File can not be null!");
this.data = new HashMap<String, Object>();
this.file = tmpl;
parseTemplate(FileUtil.getContent(file));