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

Average speed is reported incorrectly for resumed downloads #1516

Open
2 tasks done
sankalp-khare opened this issue Jun 27, 2023 · 1 comment
Open
2 tasks done

Average speed is reported incorrectly for resumed downloads #1516

sankalp-khare opened this issue Jun 27, 2023 · 1 comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!

Comments

@sankalp-khare
Copy link

sankalp-khare commented Jun 27, 2023

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

  1. Download a file using http -dc <address> -o ./somefile
  2. Interrupt the download at a high percentage done (e.g. 95%)
  3. Resume the download with the same command in Step 1
  4. When it completes, observe the average speed printed

The code to compute average speed this divides total file size by the time spent in the current (resumed) invocation of httpie. so the output is a much higher average speed than actual.

We should keep track of how much of the file was downloaded in the current invocation and use that as the numerator over here: https://github.com/httpie/httpie/blob/30a6f73ec806393d897247b4c7268832de811ff7/httpie/output/ui/rich_progress.py#L41

Current result

When I download the last 10% of a file at 5MB/s, the printed average speed is 50MB/s (1/10 the file size => 10x the speed)

Expected result

When I download the last 10% of a file at 5MB/s, the printed average speed should be 5MB/s


Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

$ http --debug <COMPLETE ARGUMENT LIST THAT TRIGGERS THE ERROR>
<COMPLETE OUTPUT>

Additional information, screenshots, or code examples

@sankalp-khare sankalp-khare added bug Something isn't working new Needs triage. Comments are welcome! labels Jun 27, 2023
@mikurei
Copy link

mikurei commented Jul 14, 2023

Hi, first-time contributor here, wanted to try myself at this issue :) I will propose a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

2 participants