Git init
[external/curl.git] / tests / libtest / lib567.c
1 /*****************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  */
9
10 #include "test.h"
11 #include "memdebug.h"
12
13 /*
14  * Test a simple OPTIONS request with a custom header
15  */
16 int test(char *URL)
17 {
18   CURLcode res;
19   CURL *curl;
20   struct curl_slist *custom_headers=NULL;
21
22   if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
23     fprintf(stderr, "curl_global_init() failed\n");
24     return TEST_ERR_MAJOR_BAD;
25   }
26
27   if ((curl = curl_easy_init()) == NULL) {
28     fprintf(stderr, "curl_easy_init() failed\n");
29     curl_global_cleanup();
30     return TEST_ERR_MAJOR_BAD;
31   }
32
33   /* Dump data to stdout for protocol verification */
34   test_setopt(curl, CURLOPT_HEADERDATA, stdout);
35   test_setopt(curl, CURLOPT_WRITEDATA, stdout);
36
37   test_setopt(curl, CURLOPT_URL, URL);
38   test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
39   test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
40   test_setopt(curl, CURLOPT_USERAGENT, "test567");
41
42   custom_headers = curl_slist_append(custom_headers, "Test-Number: 567");
43   test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
44
45   res = curl_easy_perform(curl);
46
47 test_cleanup:
48
49   if(custom_headers)
50     curl_slist_free_all(custom_headers);
51   curl_easy_cleanup(curl);
52   curl_global_cleanup();
53
54   return (int)res;
55 }
56