Added conditions for some robustness
This commit is contained in:
parent
930ad2b2f3
commit
31c700b738
3 changed files with 4 additions and 2 deletions
BIN
Zutil.jar
BIN
Zutil.jar
Binary file not shown.
4
src/zutil/net/http/HttpServer.java
Normal file → Executable file
4
src/zutil/net/http/HttpServer.java
Normal file → Executable file
|
|
@ -231,7 +231,7 @@ public class HttpServer extends ThreadedTCPNetworkServer{
|
||||||
out.setHeader( "Content-Type", "text/html" );
|
out.setHeader( "Content-Type", "text/html" );
|
||||||
out.setCookie( "session_id", ""+client_session.get("session_id") );
|
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);
|
pages.get(parser.getRequestURL()).respond(out, parser, client_session, cookie, request);
|
||||||
logRequest(parser, client_session, cookie, request, time);
|
logRequest(parser, client_session, cookie, request, time);
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +247,7 @@ public class HttpServer extends ThreadedTCPNetworkServer{
|
||||||
|
|
||||||
//********************************************************************************
|
//********************************************************************************
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING, "500 Internal Server Error", e);
|
logger.log(Level.SEVERE, "500 Internal Server Error", e);
|
||||||
try {
|
try {
|
||||||
if (!out.isHeaderSent())
|
if (!out.isHeaderSent())
|
||||||
out.setStatusCode(500);
|
out.setStatusCode(500);
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,8 @@ public class Templator {
|
||||||
* be regenerated if the file changes.
|
* be regenerated if the file changes.
|
||||||
*/
|
*/
|
||||||
public Templator(File tmpl) throws IOException {
|
public Templator(File tmpl) throws IOException {
|
||||||
|
if(tmpl == null)
|
||||||
|
throw new IllegalArgumentException("File can not be null!");
|
||||||
this.data = new HashMap<String, Object>();
|
this.data = new HashMap<String, Object>();
|
||||||
this.file = tmpl;
|
this.file = tmpl;
|
||||||
parseTemplate(FileUtil.getContent(file));
|
parseTemplate(FileUtil.getContent(file));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue