diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-06-17 22:21:36 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-06-17 22:23:42 +0200 |
commit | f851f768578dc096c561d57ba07ffd1004d504c0 (patch) | |
tree | e8acc4af7c02b32b038b425c1185dbb86cec11af /tests/libtest | |
parent | 0126b4a959c43933072a6b9549a7bd45bc606cb0 (diff) |
CURLFORM_STREAM: acknowledge CURLFORM_FILENAME
The CURLFORM_STREAM is documented to only insert a file name (and thus
look like a file upload) in the part if CURLFORM_FILENAME is set, but in
reality it always inserted a filename="" and if CURLFORM_FILENAME wasn't
set, it would insert insert rubbish (or possibly crash).
This is now fixed to work as documented, and test 554 has been extended
to verify this.
Reported by: Sascha Swiercy
Bug: http://curl.haxx.se/mail/lib-2011-06/0070.html
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/lib554.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index d510268e7..ed8d13f05 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -64,6 +64,7 @@ int test(char *URL) struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct WriteThis pooh; + struct WriteThis pooh2; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -85,6 +86,23 @@ int test(char *URL) if(formrc) printf("curl_formadd(1) = %d\n", (int)formrc); + /* Now add the same data with another name and make it not look like + a file upload but still using the callback */ + + pooh2.readptr = data; + pooh2.sizeleft = strlen(data); + + /* Fill in the file upload field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "callbackdata", + CURLFORM_STREAM, &pooh2, + CURLFORM_CONTENTSLENGTH, pooh2.sizeleft, + CURLFORM_END); + + if(formrc) + printf("curl_formadd(1) = %d\n", (int)formrc); + /* Fill in the filename field */ formrc = curl_formadd(&formpost, &lastptr, |