Handle null socket messages and add text coloring
This commit is contained in:
parent
f3e70a0218
commit
7241bd4aeb
@ -23,38 +23,40 @@ public class sigServer {
|
|||||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||||
String line;
|
String line;
|
||||||
line=in.readLine(); //Read the first line, this should be our request.
|
line=in.readLine(); //Read the first line, this should be our request.
|
||||||
String[] splitter = line.split(Pattern.quote(" "));
|
if (line!=null) {
|
||||||
if (splitter.length==3) {
|
String[] splitter = line.split(Pattern.quote(" "));
|
||||||
//This is valid.
|
if (splitter.length==3) {
|
||||||
if (splitter[0].equals("GET")) { //This is a GET request.
|
//This is valid.
|
||||||
if (splitter[2].equals("HTTP/1.1")||splitter[2].equals("HTTP/2.0")) {
|
if (splitter[0].equals("GET")) { //This is a GET request.
|
||||||
String[] requestSplit = splitter[1].split(Pattern.quote("?"));
|
if (splitter[2].equals("HTTP/1.1")||splitter[2].equals("HTTP/2.0")) {
|
||||||
String requestloc = requestSplit[0];
|
String[] requestSplit = splitter[1].split(Pattern.quote("?"));
|
||||||
HashMap<String,String> requestParams = new HashMap<>();
|
String requestloc = requestSplit[0];
|
||||||
if (requestSplit.length>1) {
|
HashMap<String,String> requestParams = new HashMap<>();
|
||||||
String[] params = requestSplit[1].split(Pattern.quote("&"));
|
if (requestSplit.length>1) {
|
||||||
for (String s : params) {
|
String[] params = requestSplit[1].split(Pattern.quote("&"));
|
||||||
String key = s.substring(0,s.indexOf('='));
|
for (String s : params) {
|
||||||
String value = s.substring(s.indexOf('=')+1);
|
String key = s.substring(0,s.indexOf('='));
|
||||||
requestParams.put(key,value);
|
String value = s.substring(s.indexOf('=')+1);
|
||||||
|
requestParams.put(key,value);
|
||||||
|
}
|
||||||
|
System.out.println(" ==Params for this request are: "+requestParams);
|
||||||
|
}
|
||||||
|
if (requestloc.equals("/")) {
|
||||||
|
//Send default directory.
|
||||||
|
CreateRequest(client,"200","OK","testfile.html");
|
||||||
|
} else {
|
||||||
|
CreateRequest(client,"200","OK",requestloc.replace("/",""));
|
||||||
}
|
}
|
||||||
System.out.println(" ==Params for this request are: "+requestParams);
|
|
||||||
}
|
|
||||||
if (requestloc.equals("/")) {
|
|
||||||
//Send default directory.
|
|
||||||
CreateRequest(client,"200","OK","testfile.html");
|
|
||||||
} else {
|
|
||||||
CreateRequest(client,"200","OK",requestloc.replace("/",""));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
CreateRequest(client,"501","Not Implemented","testfile.html");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
CreateRequest(client,"501","Not Implemented","testfile.html");
|
while (!(line=in.readLine()).isBlank()) {
|
||||||
|
//System.out.println(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!(line=in.readLine()).isBlank()) {
|
} catch(SocketException|NullPointerException e) {
|
||||||
//System.out.println(line);
|
|
||||||
}
|
|
||||||
} catch(SocketException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
body{
|
body{
|
||||||
font-family: Garamond, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: Garamond, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
background-color:$SITE_BACKCOL;
|
background-color:$SITE_BACKCOL;
|
||||||
|
color: #991199;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content{
|
.content{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user