Fix 404 server reply
This commit is contained in:
parent
9be451e05e
commit
8c81b86188
1 changed files with 10 additions and 1 deletions
|
@ -291,6 +291,7 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
||||||
else
|
else
|
||||||
tcpPacket.add(line); // Otherwise collect data
|
tcpPacket.add(line); // Otherwise collect data
|
||||||
}
|
}
|
||||||
|
//System.out.println("<Socket Closed>");
|
||||||
// and reopen client sock
|
// and reopen client sock
|
||||||
clientSocket.close();
|
clientSocket.close();
|
||||||
}
|
}
|
||||||
|
@ -312,6 +313,14 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
||||||
//private boolean handleRequest(LinkedList<String> packet, OutputStreamWriter pw){
|
//private boolean handleRequest(LinkedList<String> packet, OutputStreamWriter pw){
|
||||||
File requestedFile;
|
File requestedFile;
|
||||||
String reqFileName = packet.get(0).replaceAll("(^[A-z\\s]+/)|(\\s+?.*$)", "");
|
String reqFileName = packet.get(0).replaceAll("(^[A-z\\s]+/)|(\\s+?.*$)", "");
|
||||||
|
|
||||||
|
if (! nspFileSizes.containsKey(reqFileName)){
|
||||||
|
currSockPW.write(NETPacket.getCode404());
|
||||||
|
currSockPW.flush();
|
||||||
|
logPrinter.print("NET: File "+reqFileName+" doesn't exists or have 0 size. Returning 404", EMsgType.FAIL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
long reqFileSize = nspFileSizes.get(reqFileName);
|
long reqFileSize = nspFileSizes.get(reqFileName);
|
||||||
requestedFile = nspMap.get(reqFileName);
|
requestedFile = nspMap.get(reqFileName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue