2 /*****************************************************************************
4 * Project ___| | | | _ \| |
6 * | (__| |_| | _ <| |___
7 * \___|\___/|_| \_\_____|
12 #ifdef HAVE_SYS_STAT_H
19 #include <curl/mprintf.h>
23 /* build request url */
24 static char *suburl(const char *base, int i)
26 return curl_maprintf("%s%.4d", base, i);
30 * Test GET_PARAMETER: PUT, HEARTBEAT, and POST
38 struct_stat file_info;
39 char *stream_uri = NULL;
41 struct curl_slist *custom_headers=NULL;
43 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
44 fprintf(stderr, "curl_global_init() failed\n");
45 return TEST_ERR_MAJOR_BAD;
48 if ((curl = curl_easy_init()) == NULL) {
49 fprintf(stderr, "curl_easy_init() failed\n");
50 curl_global_cleanup();
51 return TEST_ERR_MAJOR_BAD;
55 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
56 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
57 test_setopt(curl, CURLOPT_VERBOSE, 1L);
59 test_setopt(curl, CURLOPT_URL, URL);
62 if((stream_uri = suburl(URL, request++)) == NULL) {
63 res = TEST_ERR_MAJOR_BAD;
66 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
70 test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
71 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
72 res = curl_easy_perform(curl);
76 if((stream_uri = suburl(URL, request++)) == NULL) {
77 res = TEST_ERR_MAJOR_BAD;
80 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
84 /* PUT style GET_PARAMETERS */
85 params = open("log/file572.txt", O_RDONLY);
86 fstat(params, &file_info);
89 paramsf = fopen("log/file572.txt", "rb");
91 fprintf(stderr, "can't open log/file572.txt\n");
92 res = TEST_ERR_MAJOR_BAD;
95 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
97 test_setopt(curl, CURLOPT_READDATA, paramsf);
98 test_setopt(curl, CURLOPT_UPLOAD, 1L);
99 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
101 res = curl_easy_perform(curl);
105 test_setopt(curl, CURLOPT_UPLOAD, 0L);
109 /* Heartbeat GET_PARAMETERS */
110 if((stream_uri = suburl(URL, request++)) == NULL) {
111 res = TEST_ERR_MAJOR_BAD;
114 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
118 res = curl_easy_perform(curl);
122 /* POST GET_PARAMETERS */
124 if((stream_uri = suburl(URL, request++)) == NULL) {
125 res = TEST_ERR_MAJOR_BAD;
128 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
132 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
133 test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
135 res = curl_easy_perform(curl);
139 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
141 /* Make sure we can do a normal request now */
142 if((stream_uri = suburl(URL, request++)) == NULL) {
143 res = TEST_ERR_MAJOR_BAD;
146 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
150 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
151 res = curl_easy_perform(curl);
162 curl_slist_free_all(custom_headers);
164 curl_easy_cleanup(curl);
165 curl_global_cleanup();