HttpURLConnection does not read the whole response

前端 未结 3 1328
迷失自我
迷失自我 2021-02-15 11:37

I use HttpURLConnection to do HTTP POST but I dont always get back the full response. I wanted to debug the problem, but when I step through each line it worked. I thought it mu

3条回答
  •  感动是毒
    2021-02-15 11:43

    Maybe I missed it, but what's the datatype of "input" in your code? Something that's strange about InputStreams in general is that the read( ... ) methods tend to block until data is available, then return only that data. You'll actually need to keep reading from your InputStream and appending to a ByteArrayInputStream or some other structure until you explicitly force a EOFException.

提交回复
热议问题