What happens during HTTP form submission?
过去多啦不再A梦
过去多啦不再A梦 2017-05-17 10:02:18
0
2
564

I developed a simple HTTP server myself, but it gets stuck every time the form is submitted. . Can anyone help me figure out where the problem is?


This is the content of my form, which is a very simple three input boxes

    if(bufferedReader.ready()) {
        StringBuilder stringBuilder = new StringBuilder() ;
        int ch ;
        while((ch = bufferedReader.read()) != -1){
            stringBuilder.append((char)ch) ;
            System.out.println(stringBuilder) ;
        }

        line = stringBuilder.toString() ;
    }
    

I encapsulated the input stream of the socket in this bufferReader, and then it got stuck every time while((ch = bufferedReader.read()) != -1){This line


#The output of the console shows that all the form content has been obtained, but why not return -1? Is it because the browser uses HTTP1.1 and is waiting for the return result to enter the next request? Or is there something wrong with my program? I use blocking IO

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
某草草

The problem has been solved, it is the problem of long links. . .

迷茫

I guess you didn’t close the socket!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template