1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
15 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
21 return CURL_READFUNC_ABORT;
27 CURLcode res=CURLE_OK;
29 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
30 fprintf(stderr, "curl_global_init() failed\n");
31 return TEST_ERR_MAJOR_BAD;
34 if ((curl = curl_easy_init()) == NULL) {
35 fprintf(stderr, "curl_easy_init() failed\n");
36 curl_global_cleanup();
37 return TEST_ERR_MAJOR_BAD;
40 /* First set the URL that is about to receive our POST. */
41 test_setopt(curl, CURLOPT_URL, URL);
43 /* Now specify we want to POST data */
44 test_setopt(curl, CURLOPT_POST, 1L);
46 /* Set the expected POST size */
47 test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
49 /* we want to use our own read function */
50 test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
52 /* pointer to pass to our read function */
53 test_setopt(curl, CURLOPT_INFILE, NULL);
55 /* get verbose debug output please */
56 test_setopt(curl, CURLOPT_VERBOSE, 1L);
58 /* include headers in the output */
59 test_setopt(curl, CURLOPT_HEADER, 1L);
61 /* Perform the request, res will get the return code */
62 res = curl_easy_perform(curl);
67 curl_easy_cleanup(curl);
68 curl_global_cleanup();