Skip to content

Downloaded files are corrupted in v4.0.3 #206

Closed

Description

@ghost1372

Files downloaded using version v4.0.3 are corrupted and cannot be downloaded completely. This issue does not occur in v3.3.4, which works as expected.

Steps to Reproduce:

Use application version v4.0.3.

Try downloading a file from a GitHub raw URL, for example:
https://raw.githubusercontent.com/ghost1372/App-Resources/refs/heads/main/AlAnvar/Translations/fa.ansarian.json
Observe that the downloaded file is incomplete or corrupted.

Expected Behavior:
The file should be downloaded fully and remain intact.

Actual Behavior:
The downloaded file is corrupted or incomplete in v4.0.3.

Additional Notes:

Downgrading to v3.3.4 resolves the issue; downloads work correctly in that version.

Activity

  1. Tartilla-TAIGO commented on Dec 22, 2025

    @Tartilla-TAIGO

    Good afternoon, I'm seeing the same problem, but I additionally check the files for the hash amount and redownload them if they are corrupted.

  2. bezzad commented on Feb 8, 2026

    @bezzad
    Owner

    I'm so sorry I tried to edit my answer, but I clicked delete and it was deleted!

    No problem. I'm looking into why this happened.

  3. ghost1372 commented on Feb 8, 2026

    @ghost1372
    ContributorAuthor

    Hopefully all GitHub notifications are being sent to my email. Here’s your previous comment:

    The issue is from HttpClient RequestConfiguration.AutomaticDecompression !
    I set this config and it download file successfully.

    new DownloadConfiguration { 
    . . .
    RequestConfiguration = {
                    AutomaticDecompression = DecompressionMethods.None,
                    Headers = ["Accept-Encoding: identity"]
                }
    }
    

    I set the default values to this config in next version to ignore compressing files.

  4. bezzad commented on Feb 9, 2026

    @bezzad
    Owner

    @ghost1372 @Tartilla-TAIGO
    Thanks for the detailed report.

    This corruption happens when downloading from GitHub raw (and similar servers) using multi-chunk / ranged downloads while the client advertises compression (e.g. Accept-Encoding: gzip, deflate, br). In that scenario the server may respond with Content-Encoding: gzip, and each chunk becomes a range of a compressed stream, which can’t be safely reassembled/decompressed per chunk — resulting in corrupted output (and sometimes an InvalidDataException, depending on where decompression occurs).

    Previous workaround

    new DownloadConfiguration { 
    . . .
    RequestConfiguration = {
                    AutomaticDecompression = DecompressionMethods.None,
                    Headers = ["Accept-Encoding: identity"]
                }
    }

    The previous suggestion about AutomaticDecompression was directionally correct, but it didn’t fully solve the issue in practice because Downloader was still forcing a default Accept-Encoding via HttpClient.DefaultRequestHeaders (hardcoded). That could override user changes like setting Accept-Encoding: identity, causing the problem to reappear.

    Fix

    I updated the default header handling so that Accept-Encoding is no longer forced in a way that breaks ranged downloads (and user-provided values like identity are respected). With this change, GitHub raw downloads should no longer be corrupted when using multiple chunks.

    Test build

    I’ve published a new version v4.1.0 for you to test. Please update to the latest package and retry the same URL.
    If it now downloads as incorrect, please share the response headers (Content-Encoding, Accept-Ranges, Content-Range) and your downloader configuration so I can reproduce it exactly.

  5. ghost1372 commented on Feb 9, 2026

    @ghost1372
    ContributorAuthor

    Thank you @bezzad i can confirm it is working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions