1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
24 #ifdef HAVE_SYS_STAT_H
31 #include <curl/mprintf.h>
35 /* build request url */
36 static char *suburl(const char *base, int i)
38 return curl_maprintf("%s%.4d", base, i);
42 * Test the Client->Server ANNOUNCE functionality (PUT style)
50 struct_stat file_info;
51 char *stream_uri = NULL;
53 struct curl_slist *custom_headers=NULL;
55 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
56 fprintf(stderr, "curl_global_init() failed\n");
57 return TEST_ERR_MAJOR_BAD;
60 if ((curl = curl_easy_init()) == NULL) {
61 fprintf(stderr, "curl_easy_init() failed\n");
62 curl_global_cleanup();
63 return TEST_ERR_MAJOR_BAD;
66 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
67 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
69 test_setopt(curl, CURLOPT_URL, URL);
71 if((stream_uri = suburl(URL, request++)) == NULL) {
72 res = TEST_ERR_MAJOR_BAD;
75 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
79 sdp = open("log/file568.txt", O_RDONLY);
80 fstat(sdp, &file_info);
83 sdpf = fopen("log/file568.txt", "rb");
85 fprintf(stderr, "can't open log/file568.txt\n");
86 res = TEST_ERR_MAJOR_BAD;
89 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
91 test_setopt(curl, CURLOPT_READDATA, sdpf);
92 test_setopt(curl, CURLOPT_UPLOAD, 1L);
93 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
96 res = curl_easy_perform(curl);
100 test_setopt(curl, CURLOPT_UPLOAD, 0L);
104 /* Make sure we can do a normal request now */
105 if((stream_uri = suburl(URL, request++)) == NULL) {
106 res = TEST_ERR_MAJOR_BAD;
109 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
113 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
114 res = curl_easy_perform(curl);
118 /* Now do a POST style one */
120 if((stream_uri = suburl(URL, request++)) == NULL) {
121 res = TEST_ERR_MAJOR_BAD;
124 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
128 custom_headers = curl_slist_append(custom_headers,
129 "Content-Type: posty goodness");
130 if(!custom_headers) {
131 res = TEST_ERR_MAJOR_BAD;
134 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
135 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
136 test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
138 res = curl_easy_perform(curl);
142 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
143 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
144 curl_slist_free_all(custom_headers);
145 custom_headers = NULL;
147 /* Make sure we can do a normal request now */
148 if((stream_uri = suburl(URL, request++)) == NULL) {
149 res = TEST_ERR_MAJOR_BAD;
152 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
156 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
157 res = curl_easy_perform(curl);
168 curl_slist_free_all(custom_headers);
170 curl_easy_cleanup(curl);
171 curl_global_cleanup();