Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some links don't download correctly #157

Open
zzl221000 opened this issue Mar 7, 2024 · 5 comments
Open

Some links don't download correctly #157

zzl221000 opened this issue Mar 7, 2024 · 5 comments

Comments

@zzl221000
Copy link

False RANGE support
https://testfileorg.netwet.net/testfile.org-1GB-%20Corrupt.zip
Perhaps a Range request header could be added to the head request to determine if Range is supported in the correct response

@xrelkd
Copy link
Owner

xrelkd commented Mar 7, 2024

@zzl221000 Thanks for the bug report.
Please help me test #158, if possible.

cargo run --bin caracal -- https://testfileorg.netwet.net/testfile.org-1GB-%20Corrupt.zip

@zzl221000
Copy link
Author

@xrelkd Not downloading correctly

root@JimZhang:~/caracal# cargo run --bin caracal -- https://testfileorg.netwet.net/testfile.org-1GB-%20Corrupt.zip
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/caracal 'https://testfileorg.netwet.net/testfile.org-1GB-%20Corrupt.zip'`
⠈ [00:00:35] [3/6 testfile.org-1GB-%20Corrupt.zip] [###########################] 37.15 MiB/s 100% 1.48 GiB/1.00 GiB (0s)

root@JimZhang:~/caracal# git branch -a
  develop
* fix/issue-157
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/feat/yew
  remotes/origin/fix/issue-157
  remotes/origin/main

@zzl221000
Copy link
Author

Alternatively, we can use hash to verify the correctness of the file.
After downloading with caracal, the hash of the file was changed.
I tried aria2 and it downloads the file correctly.

@xrelkd
Copy link
Owner

xrelkd commented Mar 8, 2024

It seems that the https://testfileorg.netwet.net/ does not allow us to fetch partial content from it every time.

The server returns status code 200 instead of status code 206, when we try to fetch partial content from it with Range header sometimes.

[crates/engine/src/fetcher/http.rs:73:9] (start, end, content_length, resp.status(), resp.headers()) = (
    1073741820,
    1073741823,
    4,
    200,
    {
        "date": "Fri, 08 Mar 2024 15:54:45 GMT",
        "content-type": "application/x-zip-compressed",
        "content-length": "1073741824",
        "connection": "keep-alive",
        "etag": "\"e7cb7d707e841c450ce7396c75224528\"",
        "last-modified": "Fri, 06 Jan 2023 10:15:32 GMT",
        "vary": "Accept-Encoding",
        "cache-control": "max-age=14400",
        "cf-cache-status": "MISS",
        "report-to": "{\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=MvkvFsocSGqGSAk6iKw%2Bd6RFviLwbIaI5VaObCKfPsfCIFYGdJo%2Fqajgn37ysg31PYIW3ta6hJRppPecOPOxvWwASZXWVsNNn0vw573Q28pvEQkDuG4t0M0E0R9miNOkFN2bXAWTNsFO\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
        "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
        "server": "cloudflare",
        "cf-ray": "8614016f9e5184db-HKG",
        "alt-svc": "h3=\":443\"; ma=86400",
    },
)
thread 'tokio-runtime-worker' panicked at crates/engine/src/fetcher/http.rs:74:9:
assertion `left == right` failed
  left: 200
 right: 206

You can use a single worker to download the file.
If you use cargo run --bin caracal -- -n 1 https://testfileorg.netwet.net/testfile.org-1GB-%20Corrupt.zip to download the file, the MD5 digest of the file is e7cb7d707e841c450ce7396c75224528.

We tested the server with wget, aria2, axel and caracal.
We found that wget and aria2 downloaded the file correctly, the MD5 digest is e7cb7d707e841c450ce7396c75224528.
Both wget and aria2 are using a single connection to fetch the file, even if you specify aria2 to use more than 2 connections.
axel and caracal downloaded the file with 6 connections, but the MD5 digest is not correct.

The only thing we can do is to refuse using multiple connections when the server does not guarantee use to fetch partial content every time.

@zzl221000
Copy link
Author

Investigated aria2's issue and it runs into the same problem, just triggered differently.
aria2/aria2#1344 (comment)
Handling of RANGE responses more cumbersome than expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants