hgoebl / DavidWebb

Lightweight Java HTTP-Client for calling JSON REST-Services (especially for Android)
https://hgoebl.github.io/DavidWebb/
MIT License
127 stars 41 forks source link

How can we get the progress of the request? #12

Open mathew-kurian opened 9 years ago

hgoebl commented 9 years ago

Currently there is no easy way of getting the progress. It's one of the features I'm thinking about to implement, but not in next future.

In the meantime, if it's really important for you, you could do following:

Create an intercepting InputStream which counts the number of read-calls (or bytes read). Wrap your real InputStream with this intercepting stream and give this to DavidWebb as body of the request. Your interception can now track the progress.

What do you use as body? byte[], File, InputStream, String, ...?

mathew-kurian commented 9 years ago

I see. Thank you. I am using an InputStream for the body.

hgoebl commented 9 years ago

Do you know the length in advance? Then you could have a look at ProxyInputStream (as an example) and let this stream call you back when bytes are read.

Obviously without the length you can just report the number of bytes transferred, but not the percentage.

I'll leave this issue open as an enhancement request, because this is one of the features requested most often.