1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, 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 https://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
33 /* build request url */
34 static char *suburl(const char *base, int i)
36 return curl_maprintf("%s%.4d", base, i);
40 * Test the Client->Server ANNOUNCE functionality (PUT style)
48 struct_stat file_info;
49 char *stream_uri = NULL;
51 struct curl_slist *custom_headers=NULL;
53 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
54 fprintf(stderr, "curl_global_init() failed\n");
55 return TEST_ERR_MAJOR_BAD;
58 if((curl = curl_easy_init()) == NULL) {
59 fprintf(stderr, "curl_easy_init() failed\n");
60 curl_global_cleanup();
61 return TEST_ERR_MAJOR_BAD;
64 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
65 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
67 test_setopt(curl, CURLOPT_URL, URL);
69 if((stream_uri = suburl(URL, request++)) == NULL) {
70 res = TEST_ERR_MAJOR_BAD;
73 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
77 sdp = open("log/file568.txt", O_RDONLY);
78 fstat(sdp, &file_info);
81 sdpf = fopen("log/file568.txt", "rb");
83 fprintf(stderr, "can't open log/file568.txt\n");
84 res = TEST_ERR_MAJOR_BAD;
87 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
89 test_setopt(curl, CURLOPT_READDATA, sdpf);
90 test_setopt(curl, CURLOPT_UPLOAD, 1L);
91 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
94 res = curl_easy_perform(curl);
98 test_setopt(curl, CURLOPT_UPLOAD, 0L);
102 /* Make sure we can do a normal request now */
103 if((stream_uri = suburl(URL, request++)) == NULL) {
104 res = TEST_ERR_MAJOR_BAD;
107 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
111 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
112 res = curl_easy_perform(curl);
116 /* Now do a POST style one */
118 if((stream_uri = suburl(URL, request++)) == NULL) {
119 res = TEST_ERR_MAJOR_BAD;
122 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
126 custom_headers = curl_slist_append(custom_headers,
127 "Content-Type: posty goodness");
128 if(!custom_headers) {
129 res = TEST_ERR_MAJOR_BAD;
132 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
133 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
134 test_setopt(curl, CURLOPT_POSTFIELDS,
135 "postyfield=postystuff&project=curl\n");
137 res = curl_easy_perform(curl);
141 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
142 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
143 curl_slist_free_all(custom_headers);
144 custom_headers = NULL;
146 /* Make sure we can do a normal request now */
147 if((stream_uri = suburl(URL, request++)) == NULL) {
148 res = TEST_ERR_MAJOR_BAD;
151 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
155 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
156 res = curl_easy_perform(curl);
166 curl_slist_free_all(custom_headers);
168 curl_easy_cleanup(curl);
169 curl_global_cleanup();