Please tell me how you can read the POST request sent by the browser to the server if the server is written on sockets. The problem is that the loop hangs. And it cannot be stopped in any way. Tried to stop when the length of the string was 0. Tried to read the Content-Length value and read BufferedReader in the for loop, null and -1 does not catch at all because the connection is not closed, and the socket is waiting for a response from the server. How to be prompt please.

    1 answer 1

    Solved a problem. I accept from the browser Content-Length. I run while(true){ BufferedReader.readLine();} interrupt the loop when the length of the line = 0; Then I run the second for(int i = 0; i<contentLength;/** Именно меньше, а не меньше или равно**/ i++){int ch = BufferedReader.read();/**Это ключевой момент. } loop for(int i = 0; i<contentLength;/** Именно меньше, а не меньше или равно**/ i++){int ch = BufferedReader.read();/**Это ключевой момент. } for(int i = 0; i<contentLength;/** Именно меньше, а не меньше или равно**/ i++){int ch = BufferedReader.read();/**Это ключевой момент. } Thus it turns out to perfectly read the post parameters from the server socket.