I am implementing HTTP file downloader. I am trying to download files in chunks , each chunk is being downloaded via separate thread.
I am seeing problem with the last chunk only. For the last chunk, the server is returning 1 byte less than requested.
HTTP GET REQUEST SENT:
GET /idman642build20.exe HTTP/1.1
Host: mirror2.internetdownloadmanager.com
Range: bytes=8388608-12243840
Connection: close
HTTP GET RESPONSE:
HTTP/1.1 206 Partial Content
Date: Sat, 31 Aug 2024 18:08:40 GMT
Server: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k
Last-Modified: Tue, 20 Aug 2024 21:29:03 GMT
ETag: "bad380-620241d5e53f9"
Accept-Ranges: bytes
Content-Length: 3855232
Content-Range: bytes 8388608-12243839/12243840
Connection: close
Content-Type: application/octet-stream
You can see above, I requested range 8388608-12243840 , but server is returning me 8388608-12243839 , i.e. 1 last byte is missing. chatGPT says it could be a bug on server. I am seeing this problem only with the last chunk of the file.
There are no bytes missing.
Content-Range: bytes 8388608-12243839/12243840
12243839 ist the maximum last-byte-pos
(see the standard) for a content of size 12243840, because counting starts with index 0.