Skip to content

Average speed is reported incorrectly for resumed downloads #1516

@sankalp-khare

Description

@sankalp-khare

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnewNeeds triage. Comments are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions