You should not read the entire request into memory if you are only going to write 1024 bytes.  You could crash the daemon by sending a large payload.  If you only want 1024 bytes, only read 1024 bytes.