1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
14 /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
15 static char data[]="this is a short string.\n";
17 static size_t data_size = sizeof(data) / sizeof(char);
19 static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
21 FILE *moo = fopen(libtest_arg2, "wb");
23 (void)clientp; /* UNUSED */
24 (void)dltotal; /* UNUSED */
25 (void)dlnow; /* UNUSED */
28 if ((size_t)ultotal == data_size && (size_t)ulnow == data_size)
29 fprintf(moo, "PASSED, UL data matched data size\n");
31 fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal);
40 CURLcode res=CURLE_OK;
42 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
43 fprintf(stderr, "curl_global_init() failed\n");
44 return TEST_ERR_MAJOR_BAD;
47 if ((curl = curl_easy_init()) == NULL) {
48 fprintf(stderr, "curl_easy_init() failed\n");
49 curl_global_cleanup();
50 return TEST_ERR_MAJOR_BAD;
53 /* First set the URL that is about to receive our POST. */
54 test_setopt(curl, CURLOPT_URL, URL);
56 /* Now specify we want to POST data */
57 test_setopt(curl, CURLOPT_POST, 1L);
59 #ifdef CURL_DOES_CONVERSIONS
60 /* Convert the POST data to ASCII */
61 test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
64 /* Set the expected POST size */
65 test_setopt(curl, CURLOPT_POSTFIELDSIZE, data_size);
66 test_setopt(curl, CURLOPT_POSTFIELDS, data);
68 /* we want to use our own progress function */
69 test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
70 test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
72 /* pointer to pass to our read function */
74 /* get verbose debug output please */
75 test_setopt(curl, CURLOPT_VERBOSE, 1L);
77 /* include headers in the output */
78 test_setopt(curl, CURLOPT_HEADER, 1L);
80 /* Perform the request, res will get the return code */
81 res = curl_easy_perform(curl);
86 curl_easy_cleanup(curl);
87 curl_global_cleanup();