I am writing an android app(written in Java) which will download images by POSTing http request to my SimpleHttpServer(written in Python).
The app POST text/json type data which includes some info about the requested image. After the server receives the request, it reads target images as bytes and continually writes the bytes into the established http pipe, so the app can read from its inputstream and write the bytes read to the local file.
Actually, the app doesn't only request one image.It sends multiple http requests to the server for many texts and images at a time.Under this high concurrency environment, some images cannot be properly downloaded. The error "java.net.ProtocolException: unexpected end of stream" occus, which basically means that the app read less bytes from inputstream than it should. For example, an image size has 20000 bytes (I get the file size from Content-Length in server response headers), and the app often only reads 19997(or 19998,19990,etc....) bytes, and then throws the exception. But if there are not many http requests at the same time, the bug will likely not happen.
I catch the packets both from server and the app with Wireshark (the server is deployed on a remote Windows Server 2008 R2). I get a "TCP Previous Segment not captured" warning from app side, every time, so I belive that's the breakpoint. But what should I do next to analyze the packages?
Download address: http://118.89.144.241/index2.html (The port 6000 is the port where app communicate with the server, and the port 6000 always represents the server side)