| View previous topic :: View next topic |
| Author |
Message |
dbeyer3069
Joined: 19 Dec 2005 Posts: 81
|
Posted: Tue Jan 31, 2006 8:21 am Post subject: libcurl/resume |
|
|
Has anyone figured out how to get libcurl to report back the ORIGINAL file size when doing a RESUME operation? Or a flag that indicates that curl actually is doing a resume? Curl reports the BYTES REMAINING during a resume operation.
As the library looks to me (and it works in my app), you pass the offset of the file to start at with the resume_from_large or resume_from and then it does its thing if it can. But there's no guarantee that the server on the other side supports resume so reporting the current progress is skewed. In a perfect world with a resume working 100% of the time, I'd just add the offset to the "d" field value (bytes received this session) and get the number of bytes received so far. If the resume isn't supported for that transfer though... that won't work.
I don't see a flag to indicate a resume has indeed been started/accepted... or found a field (such as in curlinfo_xxx) reporting the original size.
David Beyer |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Tue Jan 31, 2006 10:08 am Post subject: |
|
|
I haven't done any resuming or anything with libcurl yet, so I can't help you.
You may get a better response on the libcurl mailing list, or having a look through the online docs.
http://curl.haxx.se/libcurl/
Anything there will apply to using it on psp aswell. |
|
| Back to top |
|
 |
dbeyer3069
Joined: 19 Dec 2005 Posts: 81
|
Posted: Tue Jan 31, 2006 11:11 am Post subject: |
|
|
| danzel wrote: | I haven't done any resuming or anything with libcurl yet, so I can't help you.
You may get a better response on the libcurl mailing list, or having a look through the online docs.
http://curl.haxx.se/libcurl/
Anything there will apply to using it on psp aswell. |
Looks pretty sparse in there for C++ :)
I am sending an email to the mailing list. Thanks.
UPDATE: it rejected my email :) do you know if I'd get lots of emails from the mailing list or just a few? I get enough junk mail as it is :)
The resume works great but I want to add the extra bells and whistles for our PSP users :)
David Beyer |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Tue Jan 31, 2006 1:16 pm Post subject: |
|
|
well there is a progress callback that gets called to tell you how much needs to be downloaded etc.
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROGRESSFUNCTION
looks like what you want ;)
the callback prototype is:
| Code: | typedef int (*curl_progress_callback)(void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow); |
hope that helps :) |
|
| Back to top |
|
 |
dbeyer3069
Joined: 19 Dec 2005 Posts: 81
|
Posted: Tue Jan 31, 2006 1:45 pm Post subject: |
|
|
| danzel wrote: | well there is a progress callback that gets called to tell you how much needs to be downloaded etc.
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROGRESSFUNCTION
looks like what you want ;)
the callback prototype is:
| Code: | typedef int (*curl_progress_callback)(void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow); |
hope that helps :) |
Thanks for trying...
This is the function that I use already to get the info.
During downloading when NOT resuming (file offset = 0), the dltotal and dlnow report the original file size because the # of remaining bytes is the same as the original size. When it's a RESUME dltotal and dlnow reflect the bytes REMAINING (original size minus whatever offset you pass to the resume function). The problem is that a resume isn't guaranteed since not all servers support it. In that case, it looks a bit odd when you know a file is larger than what it is reporting. If there was a way to KNOW that a resume is in progress, I would just add the offset to both dltotal and dlnow when I display it.
For example:
1. ORIGINAL FILE SIZE = 5 MEGS (curl reports 5 megs to download)
2. DOWNLOAD INTERRUPTED 3 MEGS INTO IT
3. DOWNLOAD RESUMED WITH 3 MEG OFFSET (curl now reports the file size is 2 megs)
4. Once the download is complete, the final file is 5 megs and is accurate but the reporting during the download is skewed.
I checked all their curlinfo_ reporting and it returns the same values as the dltotal and dlnow.
See what I mean? The resume and download works fine but It would be nice to show logical info on the screen (what people are expecting to see).
I'll figure out a way to get the original file size on resume. If nothing else, this will save others writing future apps from having to figure out how it works.
David Beyer |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Tue Jan 31, 2006 9:24 pm Post subject: |
|
|
Well since you are passing in the offset of where to resume from, you could use that to work out the numbers you want ;)
Perhaps pass the offset into the CURLOPT_PROGRESSDATA and then use it in the callback function, adding the amount onto both dltotal and dlnow to get correct values. Pass in a value of 0 to CURLOPT_PROGRESSDATA when not resuming so you add 0 :) |
|
| Back to top |
|
 |
dbeyer3069
Joined: 19 Dec 2005 Posts: 81
|
Posted: Wed Feb 01, 2006 2:57 am Post subject: |
|
|
| danzel wrote: | Well since you are passing in the offset of where to resume from, you could use that to work out the numbers you want ;)
Perhaps pass the offset into the CURLOPT_PROGRESSDATA and then use it in the callback function, adding the amount onto both dltotal and dlnow to get correct values. Pass in a value of 0 to CURLOPT_PROGRESSDATA when not resuming so you add 0 :) |
As said, there's no way to know if a RESUME is in progress even if you pass in the offset. You could pass the offset and then curl determines its not possible to resume once it talks to the server. In that case, it would start from the beginning anyways....even though you gave it an offset.
David Beyer |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Wed Feb 01, 2006 8:03 am Post subject: |
|
|
ah yeah.... hhhhmmmm.
Might be worth taking it to the mailing list, I'd assume there is a way, but I don't know how and haven't found anything with google.
One more idea you've probally already thought of:
Since you know the full size the first time you try download it, you can tell if its resumes because the size it returns will be smaller than the total size originally given, if it doesn't resume it will be the same. |
|
| Back to top |
|
 |
|