From: Daniel Stenberg Date: Mon, 13 Jun 2011 20:05:13 +0000 (+0200) Subject: curl_formget: treat CURLFORM_STREAM better X-Git-Tag: curl-7_21_7~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85881f9f35832dbd4ef28940267f8fa30cbb867e;p=thirdparty%2Fcurl.git curl_formget: treat CURLFORM_STREAM better If a piece is set to use a callback to get the data, it should not be treated as data. It unfortunately also requires that curl_easy_perform() or similar has been used as otherwise the callback function hasn't been figured out and curl_formget won't know how to get the content. --- diff --git a/lib/formdata.c b/lib/formdata.c index df4094c33e..49e7954531 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -875,7 +875,7 @@ int curl_formget(struct curl_httppost *form, void *arg, return (int)rc; for(ptr = data; ptr; ptr = ptr->next) { - if(ptr->type == FORM_FILE) { + if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) { char buffer[8192]; size_t nread; struct Form temp; @@ -1301,8 +1301,12 @@ static size_t readfromfile(struct Form *form, char *buffer, size_t nread; bool callback = (bool)(form->data->type == FORM_CALLBACK); - if(callback) - nread = form->fread_func(buffer, 1, size, form->data->line); + if(callback) { + if(form->fread_func == ZERO_NULL) + return 0; + else + nread = form->fread_func(buffer, 1, size, form->data->line); + } else { if(!form->fp) { /* this file hasn't yet been opened */