Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / tests / libtest / lib513.c
blobddc56cd856660164c320110725b91bff401eae37
1 /*****************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * $Id: lib513.c,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
9 */
11 #include "test.h"
13 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
15 (void)ptr;
16 (void)size;
17 (void)nmemb;
18 (void)userp;
19 return CURL_READFUNC_ABORT;
22 int test(char *URL)
24 CURL *curl;
25 CURLcode res=CURLE_OK;
27 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
28 fprintf(stderr, "curl_global_init() failed\n");
29 return TEST_ERR_MAJOR_BAD;
32 if ((curl = curl_easy_init()) == NULL) {
33 fprintf(stderr, "curl_easy_init() failed\n");
34 curl_global_cleanup();
35 return TEST_ERR_MAJOR_BAD;
38 /* First set the URL that is about to receive our POST. */
39 curl_easy_setopt(curl, CURLOPT_URL, URL);
41 /* Now specify we want to POST data */
42 curl_easy_setopt(curl, CURLOPT_POST, 1L);
44 /* Set the expected POST size */
45 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
47 /* we want to use our own read function */
48 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
50 /* pointer to pass to our read function */
51 curl_easy_setopt(curl, CURLOPT_INFILE, NULL);
53 /* get verbose debug output please */
54 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
56 /* include headers in the output */
57 curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
59 /* Perform the request, res will get the return code */
60 res = curl_easy_perform(curl);
62 /* always cleanup */
63 curl_easy_cleanup(curl);
64 curl_global_cleanup();
66 return (int)res;