1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
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 the Client->Server ANNOUNCE functionality (PUT style)
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;
54 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
55 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
57 test_setopt(curl, CURLOPT_URL, URL);
59 if((stream_uri = suburl(URL, request++)) == NULL) {
60 res = TEST_ERR_MAJOR_BAD;
63 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
67 sdp = open("log/file568.txt", O_RDONLY);
68 fstat(sdp, &file_info);
71 sdpf = fopen("log/file568.txt", "rb");
73 fprintf(stderr, "can't open log/file568.txt\n");
74 res = TEST_ERR_MAJOR_BAD;
77 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
79 test_setopt(curl, CURLOPT_READDATA, sdpf);
80 test_setopt(curl, CURLOPT_UPLOAD, 1L);
81 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
84 res = curl_easy_perform(curl);
88 test_setopt(curl, CURLOPT_UPLOAD, 0L);
92 /* Make sure we can do a normal request now */
93 if((stream_uri = suburl(URL, request++)) == NULL) {
94 res = TEST_ERR_MAJOR_BAD;
97 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
101 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
102 res = curl_easy_perform(curl);
106 /* Now do a POST style one */
108 if((stream_uri = suburl(URL, request++)) == NULL) {
109 res = TEST_ERR_MAJOR_BAD;
112 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
116 custom_headers = curl_slist_append(custom_headers,
117 "Content-Type: posty goodness");
118 if(!custom_headers) {
119 res = TEST_ERR_MAJOR_BAD;
122 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
123 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
124 test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
126 res = curl_easy_perform(curl);
130 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
131 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
132 curl_slist_free_all(custom_headers);
133 custom_headers = NULL;
135 /* Make sure we can do a normal request now */
136 if((stream_uri = suburl(URL, request++)) == NULL) {
137 res = TEST_ERR_MAJOR_BAD;
140 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
144 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
145 res = curl_easy_perform(curl);
156 curl_slist_free_all(custom_headers);
158 curl_easy_cleanup(curl);
159 curl_global_cleanup();