This commit is contained in:
Ziver Koc 2015-03-23 21:05:51 +00:00
parent e822a4b35c
commit 91cadbb301
20 changed files with 342 additions and 130 deletions

View file

@ -199,7 +199,7 @@ public class HttpPrintStream extends PrintStream{
super.print(req_type+" "+req_url+" HTTP/1.0");
else
super.print("HTTP/1.0 "+res_status_code+" "+getStatusString(res_status_code));
super.println();
super.print(System.lineSeparator());
res_status_code = null;
req_type = null;
req_url = null;
@ -207,7 +207,7 @@ public class HttpPrintStream extends PrintStream{
if(headers != null){
for(String key : headers.keySet()){
super.print(key+": "+headers.get(key));
super.println();
super.print(System.lineSeparator());
}
headers = null;
}
@ -218,16 +218,16 @@ public class HttpPrintStream extends PrintStream{
for(String key : cookies.keySet()){
super.print(key+"="+cookies.get(key)+"; ");
}
super.println();
super.print(System.lineSeparator());
}
else{
for(String key : cookies.keySet()){
super.print("Set-Cookie: "+key+"="+cookies.get(key)+";");
super.println();
super.print(System.lineSeparator());
}
}
}
super.println();
super.print(System.lineSeparator());
cookies = null;
}
super.print(s);

View file

@ -53,7 +53,6 @@ public class HttpServer extends ThreadedTCPNetworkServer{
public static final int COOKIE_TTL = 200;
public static final int SESSION_TTL = 10*60*1000; // in milliseconds
public final String server_url;
public final int server_port;
private Map<String,HttpPage> pages;
@ -63,26 +62,23 @@ public class HttpServer extends ThreadedTCPNetworkServer{
/**
* Creates a new instance of the sever
*
* @param url The address to the server
*
* @param port The port that the server should listen to
*/
public HttpServer(String url, int port){
this(url, port, null, null);
public HttpServer(int port){
this(port, null, null);
}
/**
* Creates a new instance of the sever
*
* @param url The address to the server
*
* @param port The port that the server should listen to
* @param keyStore If this is not null then the server will use SSL connection with this keyStore file path
* @param keyStorePass If this is not null then the server will use a SSL connection with the given certificate
*/
public HttpServer(String url, int port, File keyStore, String keyStorePass){
public HttpServer(int port, File keyStore, String keyStorePass){
super( port, keyStore, keyStorePass );
this.server_url = url;
this.server_port = port;
pages = new ConcurrentHashMap<String,HttpPage>();