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

Add Download Progress Monitor #336

Closed
LywLover opened this issue Feb 19, 2020 · 5 comments
Closed

Add Download Progress Monitor #336

LywLover opened this issue Feb 19, 2020 · 5 comments
Labels
Feature Request Valid feature request to add to the backlog

Comments

@LywLover
Copy link

Is your feature request related to a problem? Please describe.
I need download large files and provide some time of progress bar to a user

Describe the solution you'd like
Add Download Progress Monitor like uploadMonitor :)

@ryber
Copy link
Collaborator

ryber commented Feb 19, 2020

When you download them what "asResult" method are you using? asFile()? or something else?

@LywLover
Copy link
Author

I using asFile()

@ryber ryber added the Feature Request Valid feature request to add to the backlog label Feb 20, 2020
@ryber
Copy link
Collaborator

ryber commented Feb 20, 2020

I've got a version of this working locally. It needs a little cleanup. I'll probably release something this weekend.

However, just a warning. The length of the body is not entirely determinable. We will use the following in order:

  1. The Content-Length header if present (it is not required strictly)
  2. The available bytes from the input stream which is maybe a horrible thing to try and use. I'm going to do some tests with different downloads to see how accurate it is. If it's not accurate at all I might just say it's Content-Length or nothing.

Both of these are impacted by streaming connections. If the server just keeps feeding bytes without telling me the length then Unirest is just going to keep reading until it's gone. We will hit up the monitor on the buffer but there is a chance the total size will be zero. This might be ok for a spinner, but not great for a bar or estimated time of completion.

@ryber
Copy link
Collaborator

ryber commented Feb 20, 2020

(if you or anyone else has some magical way of knowing the length of an input stream without reading it I'm more than open to suggestions)

@ryber
Copy link
Collaborator

ryber commented Feb 22, 2020

complete in 3.6.00

@LywLover LywLover closed this as completed Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Valid feature request to add to the backlog
Projects
None yet
Development

No branches or pull requests

2 participants