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
33 /* build request url */
34 static char *suburl(const char *base, int i)
36 return curl_maprintf("%s%.4d", base, i);
40 * Test GET_PARAMETER: PUT, HEARTBEAT, and POST
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;
65 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
66 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
67 test_setopt(curl, CURLOPT_VERBOSE, 1L);
69 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 test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
81 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
82 res = curl_easy_perform(curl);
86 if((stream_uri = suburl(URL, request++)) == NULL) {
87 res = TEST_ERR_MAJOR_BAD;
90 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
94 /* PUT style GET_PARAMETERS */
95 params = open("log/file572.txt", O_RDONLY);
96 fstat(params, &file_info);
99 paramsf = fopen("log/file572.txt", "rb");
100 if(paramsf == NULL) {
101 fprintf(stderr, "can't open log/file572.txt\n");
102 res = TEST_ERR_MAJOR_BAD;
105 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
107 test_setopt(curl, CURLOPT_READDATA, paramsf);
108 test_setopt(curl, CURLOPT_UPLOAD, 1L);
109 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
111 res = curl_easy_perform(curl);
115 test_setopt(curl, CURLOPT_UPLOAD, 0L);
119 /* Heartbeat GET_PARAMETERS */
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 res = curl_easy_perform(curl);
132 /* POST GET_PARAMETERS */
134 if((stream_uri = suburl(URL, request++)) == NULL) {
135 res = TEST_ERR_MAJOR_BAD;
138 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
142 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
143 test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
145 res = curl_easy_perform(curl);
149 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
151 /* Make sure we can do a normal request now */
152 if((stream_uri = suburl(URL, request++)) == NULL) {
153 res = TEST_ERR_MAJOR_BAD;
156 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
160 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
161 res = curl_easy_perform(curl);
171 curl_slist_free_all(custom_headers);
173 curl_easy_cleanup(curl);
174 curl_global_cleanup();