I have made an HTTP server, and here are some questions. Let's say - when server is receiving HTTP header - it is also counting data received size. If some hacker trying to send let's say header which is 100 MB, and server is configured to accept up to 1 MB header - how to proceed in this situation? I can close connection, or break this loop and send response with some error code:
BufferedInputStream is = new BufferedInputStream(socket.getInputStream(), 2048);
int read;
while ((read = is.read(bufferData, 0, 2048)) != -1) {
//If header too long - what to do? Break and close connection or just break and send response?
}
If I suddenly stop receiving data (while client is still transmitting) - and then will begin write some date to OutputStream
- what would happen?