Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / tests / libtest / lib544.c
blob0fbd0e28febab953df19e7f2a68499942df6165b
1 /*****************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * $Id: lib544.c,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
9 */
11 #include "test.h"
14 static char teststring[] =
15 "This\0 is test binary data with an embedded NUL byte\n";
18 int test(char *URL)
20 CURL *curl;
21 CURLcode res=CURLE_OK;
23 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
24 fprintf(stderr, "curl_global_init() failed\n");
25 return TEST_ERR_MAJOR_BAD;
28 if ((curl = curl_easy_init()) == NULL) {
29 fprintf(stderr, "curl_easy_init() failed\n");
30 curl_global_cleanup();
31 return TEST_ERR_MAJOR_BAD;
34 /* First set the URL that is about to receive our POST. */
35 curl_easy_setopt(curl, CURLOPT_URL, URL);
37 #ifdef LIB545
38 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
39 #endif
41 curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
43 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
44 curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
46 /* Update the original data to detect non-copy. */
47 strcpy(teststring, "FAIL");
49 /* Now, this is a POST request with binary 0 embedded in POST data. */
50 res = curl_easy_perform(curl);
52 /* always cleanup */
53 curl_easy_cleanup(curl);
54 curl_global_cleanup();
56 return (int)res;