Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / tests / libtest / lib514.c
blob40c21debc0de7fc21b6209b911556c74c7285e6f
1 /*****************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * $Id: lib514.c,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
9 */
11 #include "test.h"
13 int test(char *URL)
15 CURL *curl;
16 CURLcode res=CURLE_OK;
18 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
19 fprintf(stderr, "curl_global_init() failed\n");
20 return TEST_ERR_MAJOR_BAD;
23 if ((curl = curl_easy_init()) == NULL) {
24 fprintf(stderr, "curl_easy_init() failed\n");
25 curl_global_cleanup();
26 return TEST_ERR_MAJOR_BAD;
29 /* First set the URL that is about to receive our POST. */
30 curl_easy_setopt(curl, CURLOPT_URL, URL);
32 /* Based on a bug report by Niels van Tongeren on June 29, 2004:
34 A weird situation occurs when request 1 is a POST request and the request
35 2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS,
36 CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we
37 set the CURLOPT_NOBODY option to '1'.
41 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo");
42 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
43 curl_easy_setopt(curl, CURLOPT_POST, 1L);
45 /* this is where transfer 1 would take place, but skip that and change
46 options right away instead */
48 curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
50 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
51 curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
53 /* Now, we should be making a fine HEAD request */
55 /* Perform the request 2, res will get the return code */
56 res = curl_easy_perform(curl);
58 /* always cleanup */
59 curl_easy_cleanup(curl);
60 curl_global_cleanup();
62 return (int)res;