1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
17 CURLcode res=CURLE_OK;
19 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
20 fprintf(stderr, "curl_global_init() failed\n");
21 return TEST_ERR_MAJOR_BAD;
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;
30 /* First set the URL that is about to receive our POST. */
31 test_setopt(curl, CURLOPT_URL, URL);
33 /* Based on a bug report by Niels van Tongeren on June 29, 2004:
35 A weird situation occurs when request 1 is a POST request and the request
36 2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS,
37 CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we
38 set the CURLOPT_NOBODY option to '1'.
42 test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
43 test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
44 test_setopt(curl, CURLOPT_POST, 1L);
46 /* this is where transfer 1 would take place, but skip that and change
47 options right away instead */
49 test_setopt(curl, CURLOPT_NOBODY, 1L);
51 test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
52 test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
54 /* Now, we should be making a fine HEAD request */
56 /* Perform the request 2, res will get the return code */
57 res = curl_easy_perform(curl);
62 curl_easy_cleanup(curl);
63 curl_global_cleanup();