1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
13 #ifdef HAVE_SYS_STAT_H
20 #include <curl/mprintf.h>
24 /* build request url */
25 static char *suburl(const char *base, int i)
27 return curl_maprintf("%s%.4d", base, i);
31 * Test the Client->Server ANNOUNCE functionality (PUT style)
39 struct_stat file_info;
40 char *stream_uri = NULL;
42 struct curl_slist *custom_headers=NULL;
44 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
45 fprintf(stderr, "curl_global_init() failed\n");
46 return TEST_ERR_MAJOR_BAD;
49 if ((curl = curl_easy_init()) == NULL) {
50 fprintf(stderr, "curl_easy_init() failed\n");
51 curl_global_cleanup();
52 return TEST_ERR_MAJOR_BAD;
55 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
56 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
58 test_setopt(curl, CURLOPT_URL, URL);
60 if((stream_uri = suburl(URL, request++)) == NULL) {
61 res = TEST_ERR_MAJOR_BAD;
64 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
68 sdp = open("log/file568.txt", O_RDONLY);
69 fstat(sdp, &file_info);
72 sdpf = fopen("log/file568.txt", "rb");
74 fprintf(stderr, "can't open log/file568.txt\n");
75 res = TEST_ERR_MAJOR_BAD;
78 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
80 test_setopt(curl, CURLOPT_READDATA, sdpf);
81 test_setopt(curl, CURLOPT_UPLOAD, 1L);
82 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
85 res = curl_easy_perform(curl);
89 test_setopt(curl, CURLOPT_UPLOAD, 0L);
93 /* Make sure we can do a normal request now */
94 if((stream_uri = suburl(URL, request++)) == NULL) {
95 res = TEST_ERR_MAJOR_BAD;
98 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
102 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
103 res = curl_easy_perform(curl);
107 /* Now do a POST style one */
109 if((stream_uri = suburl(URL, request++)) == NULL) {
110 res = TEST_ERR_MAJOR_BAD;
113 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
117 custom_headers = curl_slist_append(custom_headers,
118 "Content-Type: posty goodness");
119 if(!custom_headers) {
120 res = TEST_ERR_MAJOR_BAD;
123 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
124 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
125 test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
127 res = curl_easy_perform(curl);
131 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
132 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
133 curl_slist_free_all(custom_headers);
134 custom_headers = NULL;
136 /* Make sure we can do a normal request now */
137 if((stream_uri = suburl(URL, request++)) == NULL) {
138 res = TEST_ERR_MAJOR_BAD;
141 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
145 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
146 res = curl_easy_perform(curl);
157 curl_slist_free_all(custom_headers);
159 curl_easy_cleanup(curl);
160 curl_global_cleanup();