Skip to content
Snippets Groups Projects
Commit 3e91f1dd authored by Stefan Rosenlund's avatar Stefan Rosenlund
Browse files

Added success byte

parent 13aea610
No related branches found
No related tags found
No related merge requests found
......@@ -145,19 +145,23 @@ public class Server {
OutputStream stream = client.getOutputStream();
byte[] result = new byte[0];
byte[] success = {0};
if (read.equals("LIST")) {
result = this.list().getBytes();
success[0] = 1;
} else if (read.matches("^GET .+")) {
String path = read.substring(4);
result = this.getFileContent(path);
success[0] = 1;
} else {
String message = "Not supported command!";
result = message.getBytes();
}
short length = (short) result.length;
ByteBuffer buffer = ByteBuffer.allocate(length + 2);
short length = (short) (result.length + 1);
ByteBuffer buffer = ByteBuffer.allocate(length + 3);
buffer.putShort(length);
buffer.put(success);
buffer.put(result);
stream.write(buffer.array());
stream.flush();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment