Git init
[external/curl.git] / tests / libtest / lib515.c
1 /*****************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  */
9
10 #include "test.h"
11
12 #include "memdebug.h"
13
14 int test(char *URL)
15 {
16   CURL *curl;
17   CURLcode res=CURLE_OK;
18
19   if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
20     fprintf(stderr, "curl_global_init() failed\n");
21     return TEST_ERR_MAJOR_BAD;
22   }
23
24   if ((curl = curl_easy_init()) == NULL) {
25     fprintf(stderr, "curl_easy_init() failed\n");
26     curl_global_cleanup();
27     return TEST_ERR_MAJOR_BAD;
28   }
29
30   /* First set the URL that is about to receive our POST. */
31   test_setopt(curl, CURLOPT_URL, URL);
32   test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
33   test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
34   test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
35   test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
36
37   /* Now, we should be making a zero byte POST request */
38   res = curl_easy_perform(curl);
39
40 test_cleanup:
41
42   /* always cleanup */
43   curl_easy_cleanup(curl);
44   curl_global_cleanup();
45
46   return (int)res;
47 }