Skip to content

fix(common): Handle downloads from sources that don’t provide a "Content-Length" header#3045

Open
kbatalin wants to merge 1 commit intosoimort:developfrom
kbatalin:develop
Open

fix(common): Handle downloads from sources that don’t provide a "Content-Length" header#3045
kbatalin wants to merge 1 commit intosoimort:developfrom
kbatalin:develop

Conversation

@kbatalin
Copy link
Copy Markdown

In some cases, sources do not return the Content-Length header. This can happen due to a proxy or simply because the source does not include it by design.

Currently, you-get either:

  • Attempts to download the next range with an invalid Range header (out of bounds), resulting in an HTTP error, or
  • Gets stuck in an infinite loop of attempts.

This PR fixes the issue by adjusting the exit condition: If the expected file size is infinite (i.e., undetermined) and the buffer has been fully read, the loop exits successfully.

Additionally, this PR includes other fixes to ensure proper functionality:

  • Correctly processes URLs when provided as a list with a single element.
  • Prevents deleting the temporary file in this case, as it is actually the final result, not a temporary file.

A test has been added to reproduce and verify the issue.

…ent-Length" header

In some cases, sources do not return the Content-Length header. This can happen due to a proxy or simply because the source does not include it by design.

Currently, you-get either:
- Attempts to download the next range with an invalid Range header (out of bounds), resulting in an HTTP error, or
- Gets stuck in an infinite loop of attempts.

This PR fixes the issue by adjusting the exit condition:
If the expected file size is infinite (i.e., undetermined) and the buffer has been fully read, the loop exits successfully.

Additionally, this PR includes other fixes to ensure proper functionality:
- Correctly processes URLs when provided as a list with a single element.
- Prevents deleting the temporary file in this case, as it is actually the final result, not a temporary file.

A test has been added to reproduce and verify the issue.
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

Successfully merging this pull request may close these issues.

1 participant