* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, 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.
+ * are also available at https://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
#endif
}
-int test(char *URL)
+static int once(char *URL, bool oldstyle)
{
CURL *curl;
CURLcode res=CURLE_OK;
struct WriteThis pooh;
struct WriteThis pooh2;
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
-
pooh.readptr = data;
pooh.sizeleft = strlen(data);
/* Fill in the file upload field */
- formrc = curl_formadd(&formpost,
- &lastptr,
- CURLFORM_COPYNAME, "sendfile",
- CURLFORM_STREAM, &pooh,
- CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
- CURLFORM_FILENAME, "postit2.c",
- CURLFORM_END);
+ if(oldstyle) {
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "sendfile",
+ CURLFORM_STREAM, &pooh,
+ CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
+ CURLFORM_FILENAME, "postit2.c",
+ CURLFORM_END);
+ }
+ else {
+ /* new style */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "sendfile alternative",
+ CURLFORM_STREAM, &pooh,
+ CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
+ CURLFORM_FILENAME, "file name 2",
+ CURLFORM_END);
+ }
if(formrc)
printf("curl_formadd(1) = %d\n", (int)formrc);
/* always cleanup */
curl_easy_cleanup(curl);
- curl_global_cleanup();
/* now cleanup the formpost chain */
curl_formfree(formpost);
return res;
}
+
+int test(char *URL)
+{
+ int res;
+
+ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ res = once(URL, TRUE); /* old */
+ if(!res)
+ res = once(URL, FALSE); /* new */
+
+ curl_global_cleanup();
+
+ return res;
+}