jquery ajax and java server, lost data

前端 未结 1 1601
青春惊慌失措
青春惊慌失措 2021-01-27 08:43

i have this ajax function that looks like so

   $.ajax({
                      type: \"POST\",
                      url: \"http://localhost:55556\",
                    


        
相关标签:
1条回答
  • 2021-01-27 09:18

    The data should come after a blank line after the header lines, but I think the problem is that the data does not end with a newline character, and therefore, you cannot read it with the .readLine() method.

    While looping through the header lines, you could look for the "Content-Length" line and get the length of the data. When you have reached the blank line, stop using .readLine(). Instead switch to reading one character at a time, reading the number of characters specified by the "Content-Length" header. I think you can find example code for this in this answer.

    If you can, I suggest you use a library to help with this. I think the Apache HTTP Core library can help with this. See this answer.

    0 讨论(0)
提交回复
热议问题