cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Progress During Posts

From: Traxler Bence <tbence_at_itm.bme.hu>
Date: 13 Nov 2002 02:31:31 +0100

Hi,

I had the same problem a month ago and I don't remember what was wrong
:) but now it's working with this:

void setFilePost(wxString id, wxArrayString* filenames, wxGauge* gauge)
{
[...]

        //Add files
        for (int i = 0; i < (int)filenames->GetCount(); i++)
        {
                curl_formadd(&form, &last, CURLFORM_COPYNAME, "files[]",
                        CURLFORM_FILE, filenames->Item(i).c_str(), CURLFORM_END);
        }

        [... setting other from fields ... ]

        //Set curl options
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, form);
        curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
        curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressUpdater);
        curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, gauge);

        [...]
}

int progressUpdater(wxGauge* gauge, double dltotal, double dlnow, double
ultotal, double ulnow)
{
        gauge->SetValue(gauge->GetValue() + (int)((double)(ulnow * 100) /
(double)ultotal));
        ::wxYield();
        return 0;
}

Miles Clark wrote:
> Hello All -
>
> Does the CURLOPT_PROGRESSFUNCTION callback work for normal HTTP Posts?
> I'm doing posts with large field values (sometimes uploading a file via
> HTTP Post), and I can get the libcurl to call my callback function, but
> the values are *always* 0 for both upload and download stats.
>
> I've tried both "normal" posts and multipart posts, set the
> POSTFIELDSIZE option directly, etc. -- with no luck.
>
> Any ideas?
>
> thanks in advance!
>
> Miles
>

-------------------------------------------------------
This sf.net email is sponsored by: Are you worried about
your web server security? Click here for a FREE Thawte
Apache SSL Guide and answer your Apache SSL security
needs: http://www.gothawte.com/rd523.html
Received on 2002-11-13