00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "test.h"
00023
00024 #ifdef HAVE_SYS_STAT_H
00025 #include <sys/stat.h>
00026 #endif
00027 #ifdef HAVE_FCNTL_H
00028 #include <fcntl.h>
00029 #endif
00030
00031 #include "memdebug.h"
00032
00033
00034 static char *suburl(const char *base, int i)
00035 {
00036 return curl_maprintf("%s%.4d", base, i);
00037 }
00038
00039
00040
00041
00042 int test(char *URL)
00043 {
00044 int res;
00045 CURL *curl;
00046 int sdp;
00047 FILE *sdpf = NULL;
00048 struct_stat file_info;
00049 char *stream_uri = NULL;
00050 int request=1;
00051 struct curl_slist *custom_headers=NULL;
00052
00053 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00054 fprintf(stderr, "curl_global_init() failed\n");
00055 return TEST_ERR_MAJOR_BAD;
00056 }
00057
00058 curl = curl_easy_init();
00059 if(!curl) {
00060 fprintf(stderr, "curl_easy_init() failed\n");
00061 curl_global_cleanup();
00062 return TEST_ERR_MAJOR_BAD;
00063 }
00064
00065 test_setopt(curl, CURLOPT_HEADERDATA, stdout);
00066 test_setopt(curl, CURLOPT_WRITEDATA, stdout);
00067
00068 test_setopt(curl, CURLOPT_URL, URL);
00069
00070 stream_uri = suburl(URL, request++);
00071 if(!stream_uri) {
00072 res = TEST_ERR_MAJOR_BAD;
00073 goto test_cleanup;
00074 }
00075 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00076 free(stream_uri);
00077 stream_uri = NULL;
00078
00079 sdp = open("log/file568.txt", O_RDONLY);
00080 fstat(sdp, &file_info);
00081 close(sdp);
00082
00083 sdpf = fopen("log/file568.txt", "rb");
00084 if(sdpf == NULL) {
00085 fprintf(stderr, "can't open log/file568.txt\n");
00086 res = TEST_ERR_MAJOR_BAD;
00087 goto test_cleanup;
00088 }
00089 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
00090
00091 test_setopt(curl, CURLOPT_READDATA, sdpf);
00092 test_setopt(curl, CURLOPT_UPLOAD, 1L);
00093 test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
00094
00095
00096 res = curl_easy_perform(curl);
00097 if(res)
00098 goto test_cleanup;
00099
00100 test_setopt(curl, CURLOPT_UPLOAD, 0L);
00101 fclose(sdpf);
00102 sdpf = NULL;
00103
00104
00105 stream_uri = suburl(URL, request++);
00106 if(!stream_uri) {
00107 res = TEST_ERR_MAJOR_BAD;
00108 goto test_cleanup;
00109 }
00110 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00111 free(stream_uri);
00112 stream_uri = NULL;
00113
00114 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
00115 res = curl_easy_perform(curl);
00116 if(res)
00117 goto test_cleanup;
00118
00119
00120
00121 stream_uri = suburl(URL, request++);
00122 if(!stream_uri) {
00123 res = TEST_ERR_MAJOR_BAD;
00124 goto test_cleanup;
00125 }
00126 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00127 free(stream_uri);
00128 stream_uri = NULL;
00129
00130 custom_headers = curl_slist_append(custom_headers,
00131 "Content-Type: posty goodness");
00132 if(!custom_headers) {
00133 res = TEST_ERR_MAJOR_BAD;
00134 goto test_cleanup;
00135 }
00136 test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
00137 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
00138 test_setopt(curl, CURLOPT_POSTFIELDS,
00139 "postyfield=postystuff&project=curl\n");
00140
00141 res = curl_easy_perform(curl);
00142 if(res)
00143 goto test_cleanup;
00144
00145 test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
00146 test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
00147 curl_slist_free_all(custom_headers);
00148 custom_headers = NULL;
00149
00150
00151 stream_uri = suburl(URL, request++);
00152 if(!stream_uri) {
00153 res = TEST_ERR_MAJOR_BAD;
00154 goto test_cleanup;
00155 }
00156 test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
00157 free(stream_uri);
00158 stream_uri = NULL;
00159
00160 test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
00161 res = curl_easy_perform(curl);
00162
00163 test_cleanup:
00164
00165 if(sdpf)
00166 fclose(sdpf);
00167
00168 free(stream_uri);
00169
00170 if(custom_headers)
00171 curl_slist_free_all(custom_headers);
00172
00173 curl_easy_cleanup(curl);
00174 curl_global_cleanup();
00175
00176 return res;
00177 }
00178