I was testing a HTTP servlet implementation (kindly shared by BalusC) which supports HTTP byte range requests.
I have found some peculiar differences between different HTTP clients, and was wondering if I am not missing anything. I have used a >2G mp4 video file for my tests and was capturing packets with Wireshark. This is roughly what happens:
Samsung Galaxy SII:
- HTTP GET request for file comes, asking for byte range
[0; <almost the end of the file>] - server responds, starts to stream the file
each subsequent chunk is served within the bounds of the same HTTP response. No new HTTP request is sent (unless the video is fast forwarded to a certain position). Streaming code chunk for this is quite simple, it reads
RandomAccessFile inputand writes toOutputStream outputviabyte[] buffer:while ((read = input.read(buffer)) > 0) { output.write(buffer, 0, read); }
- HTTP GET request for file comes, asking for byte range
- iPad 1
- HTTP GET request for file comes, asking for byte range
[0; <almost the end of the file>] - server responds, starts to stream the file
- iPad gets a chunk or two and then unilaterally decides to stop accepting bytes from the server and issues a separate
GETrequest for the next chunk of the file. New range boundaries are e.g.[100, almost the end of the file]. The video is shown OK. - cycle repeats again from step 2. Left boundary always moves towards the end of the file.
- HTTP GET request for file comes, asking for byte range
I didn't investigate how exactly the connection is terminated. It could be that iPad stops sending TCP ACK packets, I suppose this doesn't really matter that much.
My problem is