Curl_formclean(&data);
return -1;
}
- } while(nread == sizeof(buffer));
+ } while(nread);
}
else {
if(ptr->length != append(arg, ptr->line, ptr->length)) {
return 0;
else
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;
}
else {
if(!form->fp) {
}
nread = fread(buffer, 1, size, form->fp);
}
- if(!nread || nread > size) {
+ if(!nread) {
/* this is the last chunk from the file, move on */
- if(!callback) {
+ if(form->fp) {
fclose(form->fp);
form->fp = NULL;
}
curl_formfree(post);
+ /* start a new formpost with a file upload and formget */
+ post = last = NULL;
+
+ rc = curl_formadd(&post, &last,
+ CURLFORM_PTRNAME, "name of file field",
+ CURLFORM_FILE, "log/test-1308",
+ CURLFORM_FILENAME, "custom named file",
+ CURLFORM_END);
+
+ fail_unless(rc == 0, "curl_formadd returned error");
+
+ rc = curl_formget(post, &total_size, print_httppost_callback);
+ fail_unless(rc == 0, "curl_formget returned error");
+ fail_unless(total_size == 847, "curl_formget got wrong size back");
+
+ curl_formfree(post);
+
UNITTEST_STOP