1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
14 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
20 return CURL_READFUNC_ABORT;
26 CURLcode res=CURLE_OK;
28 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
29 fprintf(stderr, "curl_global_init() failed\n");
30 return TEST_ERR_MAJOR_BAD;
33 if ((curl = curl_easy_init()) == NULL) {
34 fprintf(stderr, "curl_easy_init() failed\n");
35 curl_global_cleanup();
36 return TEST_ERR_MAJOR_BAD;
39 /* First set the URL that is about to receive our POST. */
40 test_setopt(curl, CURLOPT_URL, URL);
42 /* Now specify we want to POST data */
43 test_setopt(curl, CURLOPT_POST, 1L);
45 /* Set the expected POST size */
46 test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
48 /* we want to use our own read function */
49 test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
51 /* pointer to pass to our read function */
52 test_setopt(curl, CURLOPT_INFILE, NULL);
54 /* get verbose debug output please */
55 test_setopt(curl, CURLOPT_VERBOSE, 1L);
57 /* include headers in the output */
58 test_setopt(curl, CURLOPT_HEADER, 1L);
60 /* Perform the request, res will get the return code */
61 res = curl_easy_perform(curl);
66 curl_easy_cleanup(curl);
67 curl_global_cleanup();