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

zsync_legacy fails on HTTP/2 response #56

Closed jonathonf closed 3 years ago

jonathonf commented 3 years ago

Running under Arch Linux with zsync2 version 2.0.0-alpha-1 (commit 486fc9a), when attempting to download from an HTTP/2-enabled server zsync2 fails with the error:

zsync_legacy: got non-HTTP response 'HTTP/2 200

Verbose download output:

$ zsync2 -vvv -i archlinux-2021.03.01-x86_64.iso https://gitlab.archlinux.org/jonathon/archiso/-/jobs/16578/artifacts/raw/output/releng/archlinux-2021.03.04-x86_64.iso.zsync
zsync2 version 2.0.0-alpha-1 (commit 486fc9a), build <local dev build> built on 2021-03-02 22:59:06 UTC
Checking for changes...
Cannot find file archlinux-2021.03.04-x86_64.iso, triggering full download
/build/iso/archlinux-2021.03.04-x86_64.iso.part found, using as seed file
Target file: /build/iso/archlinux-2021.03.04-x86_64.iso
Reading seed file: /build/iso/archlinux-2021.03.04-x86_64.iso.part
Reading seed file: archlinux-2021.03.01-x86_64.iso
Usable data from seed files: 82.558900%
Renaming temp file
Fetching remaining blocks
Downloading from https://gitlab.archlinux.org/jonathon/archiso/-/jobs/16578/artifacts/raw/output/releng/archlinux-2021.03.04-x86_64.iso

################---- 82.6%*   Trying 2a01:4f8:c2c:5d2d::1:443...
* Connected to gitlab.archlinux.org (2a01:4f8:c2c:5d2d::1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=gitlab.archlinux.org
*  start date: Jan 23 16:51:10 2021 GMT
*  expire date: Apr 23 16:51:10 2021 GMT
*  subjectAltName: host "gitlab.archlinux.org" matched cert's "gitlab.archlinux.org"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55fe1e3cf790)
> GET /jonathon/archiso/-/jobs/16578/artifacts/raw/output/releng/archlinux-2021.03.04-x86_64.iso HTTP/2
Host: gitlab.archlinux.org
range: bytes=0-4095
accept: */*

* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200 
< server: nginx
< date: Fri, 05 Mar 2021 01:15:12 GMT
< content-type: application/x-iso9660-image
< content-length: 769994752
< cache-control: no-cache
< content-disposition: attachment; filename="archlinux-2021.03.04-x86_64.iso"
< set-cookie: experimentation_subject_id=eyJfcmFpbHMiOnsibWVzc2FnZSI6IklqYzVOakl6T1RNNExUUTVabUl0TkRZMlpTMWlOalEwTFRNM056aGxOak5oWVRsak5TST0iLCJleHAiOm51bGwsInB1ciI6ImNvb2tpZS5leHBlcmltZW50YXRpb25fc3ViamVjdF9pZCJ9fQ%3D%3D--8a9dd78ff3a947749b48451342aff6b2538164a0; path=/; expires=Tue, 05 Mar 2041 01:15:12 GMT; secure; HttpOnly; SameSite=None
< x-content-type-options: nosniff
< x-download-options: noopen
< x-frame-options: DENY
< x-gitlab-feature-category: continuous_integration
< x-permitted-cross-domain-policies: none
< x-request-id: 01EZZZ7VM16TTNAK13FXM97T7A
< x-runtime: 0.058740
< x-ua-compatible: IE=edge
< x-xss-protection: 1; mode=block
< strict-transport-security: max-age=31536000
< referrer-policy: strict-origin-when-cross-origin
< 
zsync_legacy: got non-HTTP response 'HTTP/2 200 
'

zsync_legacy: Other error? -1
* stopped the pause stream!
* Connection #0 to host gitlab.archlinux.org left intact
failed to retrieve from archlinux-2021.03.04-x86_64.iso, status -1
TheAssassin commented 3 years ago

The server apparently doesn't support range requests. This is a known issue for GitLab.

zsync2 does not support downloading from HTTP 200 responses. You should just download the file normally.

For the record: this does not have anything to do with it being HTTP 2. It's the lack of range requests.

jonathonf commented 3 years ago

this does not have anything to do with it being HTTP 2.

Not sure that's correct - the test is specifically for HTTP/1 and that means it will never download from an HTTP/2 server.

The lack of range requests is unrelated, it's just a "bad" example of a download location from that perspective.

Edit: to confirm, with #57 the error changes to the expected response for a lack of partial content:

zsync_legacy: 
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.
TheAssassin commented 3 years ago

Confirmed that #57 makes it work with HTTP/2 properly. Thanks for your contribution!