cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: libcurl PUT retry and READFUNCTION

From: Wenjun Chen <wchen_at_F5.com>
Date: Wed, 25 Jan 2012 04:13:09 +0000

> I am not sure if this is a correct usage? I will try this and run for a few hours to see if the problem is >> resolved.

> // set the put_data_callback function
> curl_easy_setopt(curl, CURLOPT_PUT, true);
> curl_easy_setopt(curl, CURLOPT_READDATA, &m_data);
> curl_easy_setopt(curl, CURLOPT_READFUNCTION, put_data_callback);
>
> curl_easy_setopt(curl, CURLOPT_SEEKDATA, &m_data);
> curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_data_callback);

> curl_easy_perform(curl);

> struct put_data_t {
> const char * data_start;
> unsigned read_pos;
> unsigned data_len;
>};

>int seek_data_callback(void *userp, curl_off_t offset, int origin)
>{
> if (!userp)
> return 0;

> put_data_t *userdata = (put_data_t *)userp;

> if (offset > userdata->data_len)
> return CURL_SEEKFUNC_FAIL;

> if (origin == SEEK_SET || origin == SEEK_CUR)
> {
> userdata->read_pos = offset;
> return CURL_SEEKFUNC_OK;
> }

> if (origin == SEEK_END)
> {
> userdata->read_pos = userdata->data_len;
> return CURL_SEEKFUNC_OK;
> }

> return CURL_SEEKFUNC_FAIL;
> }

The above code did not fix the problem. I added log message in call back funcgtions. The log output is as follows.

2012-01-24 22:59:22.000 (GMT-05:00) Write Data is 489 bytes
2012-01-24 22:59:22.000 (GMT-05:00) put_data_callback buff length 16372, data passed in 489 bytes
2012-01-24 22:59:22.000 (GMT-05:00) seek_data_callback, offset: 0, origin: 0, data len: 0

Looks like the put_data_callback is not called again after seek_data callback with SEEK_SET operation(the seek_data_callback returns CURL_SEEKFUNC_OK) . Also the data passed back in seek_data_callback is not correct (the datalen should be 489, not 0). Maybe my implementation of seek_data_callback is not correct.

Thanks,
Wenjun

> / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-01-25