search

Home  >  Q&A  >  body text

What happens during HTTP form submission?

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梦2755 days ago545

reply all(2)I'll reply

  • 某草草

    某草草2017-05-17 10:04:18

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

    reply
    0
  • 迷茫

    迷茫2017-05-17 10:04:18

    I guess you didn’t close the socket!

    reply
    0
  • Cancelreply