diff options
Diffstat (limited to 'tests/libtest/lib554.c')
-rw-r--r-- | tests/libtest/lib554.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index d7c68241..0596f3ef 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include "test.h" #include "memdebug.h" @@ -28,6 +40,14 @@ struct WriteThis { static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { +#ifdef LIB587 + (void)ptr; + (void)size; + (void)nmemb; + (void)userp; + return CURL_READFUNC_ABORT; +#else + struct WriteThis *pooh = (struct WriteThis *)userp; if(size*nmemb < 1) @@ -41,6 +61,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) } return 0; /* no more data left to deliver */ +#endif } int test(char *URL) @@ -52,6 +73,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"); @@ -66,13 +88,30 @@ int test(char *URL) &lastptr, CURLFORM_COPYNAME, "sendfile", CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTSLENGTH, pooh.sizeleft, + CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, CURLFORM_FILENAME, "postit2.c", CURLFORM_END); 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, (long)pooh2.sizeleft, + CURLFORM_END); + + if(formrc) + printf("curl_formadd(1) = %d\n", (int)formrc); + /* Fill in the filename field */ formrc = curl_formadd(&formpost, &lastptr, @@ -106,6 +145,16 @@ int test(char *URL) if(formrc) printf("curl_formadd(3) = %d\n", (int)formrc); + formrc = curl_formadd(&formpost, &lastptr, + CURLFORM_COPYNAME, "somename", + CURLFORM_BUFFER, "somefile.txt", + CURLFORM_BUFFERPTR, "blah blah", + CURLFORM_BUFFERLENGTH, (long)9, + CURLFORM_END); + + if(formrc) + printf("curl_formadd(4) = %d\n", (int)formrc); + if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_formfree(formpost); |