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 ***************************************************************************/
25 #ifdef HAVE_SYS_STAT_H
32 #include <curl/mprintf.h>
36 /* build request url */
37 static char *suburl(const char *base, int i)
39 return curl_maprintf("%s%.4d", base, i);
43 * Test the Client->Server ANNOUNCE functionality (PUT style)
51 struct_stat file_info;
52 char *stream_uri = NULL;
54 struct curl_slist *custom_headers=NULL;
56 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
57 fprintf(stderr, "curl_global_init() failed\n");
58 return TEST_ERR_MAJOR_BAD;
61 if ((curl = curl_easy_init()) == NULL) {
62 fprintf(stderr, "curl_easy_init() failed\n");
63 curl_global_cleanup();
64 return TEST_ERR_MAJOR_BAD;
67 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
68 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
70 test_setopt(curl, CURLOPT_URL, URL);
72 if((stream_uri = suburl(URL, request++)) == NULL) {
73 res = TEST_ERR_MAJOR_BAD;
76 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
80 sdp = open("log/file568.txt", O_RDONLY);
81 fstat(sdp, &file_info);
84 sdpf = fopen("log/file568.txt", "rb");
86 fprintf(stderr, "can't open log/file568.txt\n");
87 res = TEST_ERR_MAJOR_BAD;
90 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
92 test_setopt(curl, CURLOPT_READDATA, sdpf);
93 test_setopt(curl, CURLOPT_UPLOAD, 1L);
94 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
97 res = curl_easy_perform(curl);
101 test_setopt(curl, CURLOPT_UPLOAD, 0L);
105 /* Make sure we can do a normal request now */
106 if((stream_uri = suburl(URL, request++)) == NULL) {
107 res = TEST_ERR_MAJOR_BAD;
110 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
114 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
115 res = curl_easy_perform(curl);
119 /* Now do a POST style one */
121 if((stream_uri = suburl(URL, request++)) == NULL) {
122 res = TEST_ERR_MAJOR_BAD;
125 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
129 custom_headers = curl_slist_append(custom_headers,
130 "Content-Type: posty goodness");
131 if(!custom_headers) {
132 res = TEST_ERR_MAJOR_BAD;
135 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
136 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
137 test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
139 res = curl_easy_perform(curl);
143 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
144 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
145 curl_slist_free_all(custom_headers);
146 custom_headers = NULL;
148 /* Make sure we can do a normal request now */
149 if((stream_uri = suburl(URL, request++)) == NULL) {
150 res = TEST_ERR_MAJOR_BAD;
153 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
157 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
158 res = curl_easy_perform(curl);
169 curl_slist_free_all(custom_headers);
171 curl_easy_cleanup(curl);
172 curl_global_cleanup();