AppImageCommunity / zsync2

Rewrite of https://github.com/AppImage/zsync-curl, using modern C++, providing both a library and standalone tools.
Other
132 stars 25 forks source link

Lib requesting out of bound range #77

Open pkwong4321 opened 4 months ago

pkwong4321 commented 4 months ago

Got an error from zsync while updating, stating the server couldn't handle partial content. Upon inspecing with CURLOPT_VERBOSE=1 I found that it's only the last request returning full content (200) It's doing that because while the total file size is 243233088, it's requesting the range past it at 243236863.

I'm not sure how to reproduce, here is the log and the version of tools i used. OS: Debian 10 zsyncmake: 0.6.2-3 AppImageUpdate: 2.0.0-alpha-1-20230526

> GET xxx.AppImage HTTP/1.1
Host: host.com
Range: bytes=218681344-218685439
Accept: */*

< HTTP/1.1 206 Partial Content
< Server: AliyunOSS
< Date: Mon, 27 May 2024 16:22:24 GMT
< Content-Type: application/octet-stream
< Content-Length: 4096
< Connection: keep-alive
< x-oss-request-id: 6654B3402A8F622C553851A4
< Content-Range: bytes 218681344-218685439/243233088
< Accept-Ranges: bytes
< ETag: "954B7FD219F2CB384BA1E687F9A920C2-95"
< Last-Modified: Mon, 27 May 2024 04:24:38 GMT
< x-oss-object-type: Multipart
< x-oss-hash-crc64ecma: 5989594152036317672
< x-oss-storage-class: Standard
< x-oss-server-time: 29
< 
* Connection #1 to host host.com left intact
* Expire in 0 ms for 6 (transfer 0x7f7138684a40)
* Found bundle for host host.com: 0x7f71380026e0 [can pipeline]
* Could pipeline, but not asked to!
* Re-using existing connection! (#1) with host host.com
* Connected to host.com port 80 (#1)
* Expire in 0 ms for 6 (transfer 0x7f7138684a40)
> GET xxx.AppImage HTTP/1.1
Host: host.com
Range: bytes=218697728-243236863
Accept: */*

< HTTP/1.1 200 OK
< Server: AliyunOSS
< Date: Mon, 27 May 2024 16:22:25 GMT
< Content-Type: application/octet-stream
< Content-Length: 243233088
< Connection: keep-alive
< x-oss-request-id: 6654B340CE4EF5B4BF3C38C5
< Accept-Ranges: bytes
< ETag: "954B7FD219F2CB384BA1E687F9A920C2-95"
< Last-Modified: Mon, 27 May 2024 04:24:38 GMT
< x-oss-object-type: Multipart
< x-oss-hash-crc64ecma: 5989594152036317672
< x-oss-storage-class: Standard
< x-oss-server-time: 26

zsync received a data response (code 200) but this is not a partial content response
zsync can only work with servers that support returning partial content from files. The person/entity creating this .zsync has tried to use a server that is not returning partial content. zsync cannot be used with this server.
See http://zsync.moria.orc.uk/server-issues
Other error? -1
-1 returned
* Closing connection 1

Note: If I naively limit the final range to filesize-1 in fetchRemainingBlocksHttp(), the update works. It would seem to be a calculation error in the zsync calls, or and error in my generated .zsync meta?