diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-05-11 12:21:00 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-05-11 12:21:00 +0200 |
commit | c133bb1c5e23309932799b9d2f513f049a3bb22f (patch) | |
tree | 191e7d6e8b86764aadc115dea25bbd71210abff6 | |
parent | 5fd22c17e72e3ff49eb2050133958fe28750415c (diff) |
fb-helper: Remove forms array; use curl_formadd directlyv1.1.3
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | fb-helper.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/fb-helper.c b/fb-helper.c index 5a429b2..c8e4256 100644 --- a/fb-helper.c +++ b/fb-helper.c @@ -233,7 +233,6 @@ int main(int argc, char *argv[]) struct curl_httppost *lastptr = NULL; struct curl_slist *headerlist = NULL; static const char buf[] = "Expect:"; - struct curl_forms forms[4]; char *userAgent = "fb-client/"VERSION; @@ -324,27 +323,23 @@ int main(int argc, char *argv[]) goto cleanup; } - forms[0].option = CURLFORM_BUFFER; - forms[0].value = basename(options.file); - forms[1].option = CURLFORM_BUFFERPTR; - forms[1].value = data; - forms[2].option = CURLFORM_BUFFERLENGTH; - forms[2].value = (char *)data_size; - forms[3].option = CURLFORM_END; + /* Fill in the file upload field */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "file", + CURLFORM_BUFFER, basename(options.file), + CURLFORM_BUFFERPTR, data, + CURLFORM_BUFFERLENGTH, (char *)data_size, + CURLFORM_END); } else { - forms[0].option = CURLFORM_FILE; - forms[0].value = options.file; - forms[1].option = CURLFORM_END; + /* Fill in the file upload field */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "file", + CURLFORM_FILE, options.file, + CURLFORM_END); } - /* Fill in the file upload field */ - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "file", - CURLFORM_ARRAY, forms, - CURLFORM_END); - curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); - if (isatty(fileno(stderr)) == 1) { /* display progress bar*/ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); @@ -353,6 +348,8 @@ int main(int argc, char *argv[]) } } + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + /* initialize custom header list (stating that Expect: 100-continue is not wanted */ headerlist = curl_slist_append(headerlist, buf); |