curl-library
Http post + CURL_READFUNC_ABORT
Date: Wed, 12 Oct 2011 16:48:12 +0400
Hi.
Curl hangs if I return CURL_READFUNC_ABORT from readfunc callback.
The mechanics of hang is following:
1. my readfunc callback returns CURL_READFUNC_ABORT
2. formdata.c:readfromfile() function has code:
nread = form->fread_func(buffer, 1, size, form->data->line);
if(nread > size)
/* the read callback can return a value larger than the buffer but
treat any such as no data in this case */
nread = 0;
....
return nread;
So, readfromfile() casts CURL_READFUNC_ABORT to 0 and returns it.
3. formdata.c:Curl_FormReader()
if((form->data->type == FORM_FILE) ||
(form->data->type == FORM_CALLBACK)) {
gotsize = readfromfile(form, buffer, wantedsize); // <-- 0 here
if(gotsize)
/* If positive or -1, return. If zero, continue! */
return gotsize; // <--
does not return
}
do {
// <-- there are other fields
.....
gotsize += form->data->length - form->sent;
// <-- gotsize increased, in my case
it is 48 now
.....
} while(form->data && (form->data->type < FORM_CALLBACK));
return gotsize; //
<-- gotsize = 48
4. Curl_fillreadbuffer()
// nread is 48 here, CURL_READFUNC_ABORT defined as 0x10000000
nread = (int)conn->fread_func(data->req.upload_fromhere, 1,
buffersize, conn->fread_in);
if(nread == CURL_READFUNC_ABORT) { // <-- false
failf(data, "operation aborted by callback");
*nreadp = 0;
return CURLE_ABORTED_BY_CALLBACK;
}
Looks as bug to me.
---
WBR, Anton.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-12