mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Addes OOM handling for curl_easy_setopt() calls in test
This commit is contained in:
parent
12d01bc5f7
commit
cad9c3f55f
@ -29,8 +29,8 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
@ -44,6 +44,8 @@ int test(char *URL)
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -30,10 +30,12 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *c;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
int res = 0;
|
||||
int running=1;
|
||||
struct timeval mp_start;
|
||||
@ -40,7 +40,7 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||
test_setopt(c, CURLOPT_URL, URL);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
@ -81,9 +81,13 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(m) {
|
||||
curl_multi_remove_handle(m, c);
|
||||
curl_easy_cleanup(c);
|
||||
curl_multi_cleanup(m);
|
||||
}
|
||||
curl_easy_cleanup(c);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
|
@ -29,7 +29,7 @@
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *c;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
int res = 0;
|
||||
int running;
|
||||
char done = FALSE;
|
||||
@ -49,12 +49,12 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
|
||||
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing");
|
||||
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
|
||||
curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
|
||||
curl_easy_setopt(c, CURLOPT_HEADER, 1L);
|
||||
test_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
|
||||
test_setopt(c, CURLOPT_URL, URL);
|
||||
test_setopt(c, CURLOPT_USERPWD, "test:ing");
|
||||
test_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
|
||||
test_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
|
||||
test_setopt(c, CURLOPT_HEADER, 1L);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
@ -139,9 +139,13 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(m) {
|
||||
curl_multi_remove_handle(m, c);
|
||||
curl_easy_cleanup(c);
|
||||
curl_multi_cleanup(m);
|
||||
}
|
||||
curl_easy_cleanup(c);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
|
@ -28,10 +28,10 @@
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *c;
|
||||
int ret=0;
|
||||
CURLM *m;
|
||||
int res = 0;
|
||||
CURLM *m = NULL;
|
||||
fd_set rd, wr, exc;
|
||||
CURLMcode res;
|
||||
CURLMcode ret;
|
||||
char done = FALSE;
|
||||
int running;
|
||||
int max_fd;
|
||||
@ -54,9 +54,9 @@ int test(char *URL)
|
||||
|
||||
/* the point here being that there must not run anything on the given
|
||||
proxy port */
|
||||
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(c, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(c, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(c, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(c, CURLOPT_URL, URL);
|
||||
test_setopt(c, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
@ -65,9 +65,9 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
if ((res = curl_multi_add_handle(m, c)) != CURLM_OK) {
|
||||
if ((ret = curl_multi_add_handle(m, c)) != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_add_handle() failed, "
|
||||
"with code %d\n", res);
|
||||
"with code %d\n", ret);
|
||||
curl_multi_cleanup(m);
|
||||
curl_easy_cleanup(c);
|
||||
curl_global_cleanup();
|
||||
@ -93,10 +93,10 @@ int test(char *URL)
|
||||
|
||||
fprintf(stderr, "curl_multi_perform()\n");
|
||||
|
||||
res = CURLM_CALL_MULTI_PERFORM;
|
||||
ret = CURLM_CALL_MULTI_PERFORM;
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = curl_multi_perform(m, &running);
|
||||
while (ret == CURLM_CALL_MULTI_PERFORM) {
|
||||
ret = curl_multi_perform(m, &running);
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
@ -112,15 +112,15 @@ int test(char *URL)
|
||||
CURLMsg *msg = curl_multi_info_read(m, &numleft);
|
||||
fprintf(stderr, "Expected: not running\n");
|
||||
if(msg && !numleft)
|
||||
ret = 100; /* this is where we should be */
|
||||
res = 100; /* this is where we should be */
|
||||
else
|
||||
ret = 99; /* not correct */
|
||||
res = 99; /* not correct */
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "running == %d, res == %d\n", running, res);
|
||||
fprintf(stderr, "running == %d, ret == %d\n", running, ret);
|
||||
|
||||
if (res != CURLM_OK) {
|
||||
ret = 2;
|
||||
if (ret != CURLM_OK) {
|
||||
res = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ int test(char *URL)
|
||||
fprintf(stderr, "curl_multi_fdset()\n");
|
||||
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
|
||||
fprintf(stderr, "unexpected failured of fdset.\n");
|
||||
ret = 3;
|
||||
res = 3;
|
||||
break;
|
||||
}
|
||||
rc = select_test(max_fd+1, &rd, &wr, &exc, &interval);
|
||||
@ -144,14 +144,18 @@ int test(char *URL)
|
||||
if (mp_timedout) fprintf(stderr, "mp_timedout\n");
|
||||
fprintf(stderr, "ABORTING TEST, since it seems "
|
||||
"that it would have run forever.\n");
|
||||
ret = TEST_ERR_RUNS_FOREVER;
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(m) {
|
||||
curl_multi_remove_handle(m, c);
|
||||
curl_easy_cleanup(c);
|
||||
curl_multi_cleanup(m);
|
||||
}
|
||||
curl_easy_cleanup(c);
|
||||
curl_global_cleanup();
|
||||
|
||||
return ret;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -117,27 +117,29 @@ int test(char *URL)
|
||||
headerlist = hl;
|
||||
|
||||
/* enable uploading */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* enable verbose */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, URL);
|
||||
test_setopt(curl,CURLOPT_URL, URL);
|
||||
|
||||
/* pass in that last of FTP commands to run after the transfer */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
|
||||
test_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
|
||||
|
||||
/* now specify which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
|
||||
test_setopt(curl, CURLOPT_INFILE, hd_src);
|
||||
|
||||
/* and give the size of the upload (optional) */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
(curl_off_t)file_info.st_size);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* clean up the FTP commands list */
|
||||
curl_slist_free_all(headerlist);
|
||||
|
||||
|
@ -224,12 +224,12 @@ int test(char *URL)
|
||||
|
||||
url = suburl( URL, i );
|
||||
headers = sethost( NULL );
|
||||
curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers );
|
||||
curl_easy_setopt( curl, CURLOPT_URL, url );
|
||||
test_setopt( curl, CURLOPT_HTTPHEADER, headers );
|
||||
test_setopt( curl, CURLOPT_URL, url );
|
||||
printf( "CURLOPT_SHARE\n" );
|
||||
curl_easy_setopt( curl, CURLOPT_SHARE, share );
|
||||
test_setopt( curl, CURLOPT_SHARE, share );
|
||||
printf( "CURLOPT_COOKIEJAR\n" );
|
||||
curl_easy_setopt( curl, CURLOPT_COOKIEJAR, JAR );
|
||||
test_setopt( curl, CURLOPT_COOKIEJAR, JAR );
|
||||
|
||||
printf( "PERFORM\n" );
|
||||
curl_easy_perform( curl );
|
||||
@ -245,6 +245,8 @@ int test(char *URL)
|
||||
printf( "SHARE_CLEANUP failed, correct\n" );
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* clean up last handle */
|
||||
printf( "CLEANUP\n" );
|
||||
curl_easy_cleanup( curl );
|
||||
|
@ -22,8 +22,9 @@ int test(char *URL)
|
||||
CURLM* multi;
|
||||
int still_running;
|
||||
int i = -1;
|
||||
int res = 0;
|
||||
CURLMsg *msg;
|
||||
CURLMcode res;
|
||||
CURLMcode ret;
|
||||
struct timeval ml_start;
|
||||
struct timeval mp_start;
|
||||
char ml_timedout = FALSE;
|
||||
@ -47,11 +48,11 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curls, CURLOPT_URL, URL);
|
||||
test_setopt(curls, CURLOPT_URL, URL);
|
||||
|
||||
if ((res = curl_multi_add_handle(multi, curls)) != CURLM_OK) {
|
||||
if ((ret = curl_multi_add_handle(multi, curls)) != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_add_handle() failed, "
|
||||
"with code %d\n", res);
|
||||
"with code %d\n", ret);
|
||||
curl_easy_cleanup(curls);
|
||||
curl_multi_cleanup(multi);
|
||||
curl_global_cleanup();
|
||||
@ -62,13 +63,13 @@ int test(char *URL)
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
do {
|
||||
res = curl_multi_perform(multi, &still_running);
|
||||
ret = curl_multi_perform(multi, &still_running);
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
} while (res == CURLM_CALL_MULTI_PERFORM);
|
||||
} while (ret == CURLM_CALL_MULTI_PERFORM);
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = tutil_tvnow();
|
||||
@ -103,13 +104,13 @@ int test(char *URL)
|
||||
mp_timedout = FALSE;
|
||||
mp_start = tutil_tvnow();
|
||||
do {
|
||||
res = curl_multi_perform(multi, &still_running);
|
||||
ret = curl_multi_perform(multi, &still_running);
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
} while (res == CURLM_CALL_MULTI_PERFORM);
|
||||
} while (ret == CURLM_CALL_MULTI_PERFORM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -128,9 +129,14 @@ int test(char *URL)
|
||||
i = msg->data.result;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_multi_cleanup(multi);
|
||||
curl_easy_cleanup(curls);
|
||||
curl_global_cleanup();
|
||||
|
||||
if(res)
|
||||
i = res;
|
||||
|
||||
return i; /* return the final return code */
|
||||
}
|
||||
|
@ -58,34 +58,36 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now specify we want to POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* Set the expected POST size */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
|
||||
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* pointer to pass to our read function */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
|
||||
test_setopt(curl, CURLOPT_INFILE, &pooh);
|
||||
|
||||
/* get verbose debug output please */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* include headers in the output */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -72,39 +72,41 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now specify we want to POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* pointer to pass to our read function */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
|
||||
test_setopt(curl, CURLOPT_INFILE, &pooh);
|
||||
|
||||
/* get verbose debug output please */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* include headers in the output */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* enforce chunked transfer by setting the header */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, slist);
|
||||
|
||||
#ifdef LIB565
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "foo:bar");
|
||||
test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
|
||||
#endif
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* clean up the headers list */
|
||||
if(slist)
|
||||
curl_slist_free_all(slist);
|
||||
|
@ -28,13 +28,15 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
test_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -38,29 +38,31 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now specify we want to POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
/* Set the expected POST size */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
|
||||
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* pointer to pass to our read function */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, NULL);
|
||||
test_setopt(curl, CURLOPT_INFILE, NULL);
|
||||
|
||||
/* get verbose debug output please */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* include headers in the output */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -29,7 +29,7 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Based on a bug report by Niels van Tongeren on June 29, 2004:
|
||||
|
||||
@ -40,23 +40,25 @@ int test(char *URL)
|
||||
|
||||
*/
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo");
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
/* this is where transfer 1 would take place, but skip that and change
|
||||
options right away instead */
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
test_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a fine HEAD request */
|
||||
|
||||
/* Perform the request 2, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -29,15 +29,17 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a zero byte POST request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -29,14 +29,16 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HTTPPOST, NULL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Now, we should be making a zero byte POST request */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -484,11 +484,13 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
close_file_descriptors();
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -28,19 +28,21 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed");
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_USERPWD, "monster:underbed");
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* get first page */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
|
||||
test_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
|
||||
|
||||
/* get second page */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -28,12 +28,14 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -28,13 +28,15 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -28,14 +28,16 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, 19999L);
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_PORT, 19999L);
|
||||
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -28,12 +28,14 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -30,7 +30,7 @@ int test(char *URL)
|
||||
struct_stat file_info;
|
||||
int running;
|
||||
char done=FALSE;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
struct timeval ml_start;
|
||||
struct timeval mp_start;
|
||||
char ml_timedout = FALSE;
|
||||
@ -72,19 +72,19 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* enable uploading */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, URL);
|
||||
test_setopt(curl,CURLOPT_URL, URL);
|
||||
|
||||
/* go verbose */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* use active FTP */
|
||||
curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
|
||||
test_setopt(curl, CURLOPT_FTPPORT, "-");
|
||||
|
||||
/* now specify which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
test_setopt(curl, CURLOPT_READDATA, hd_src);
|
||||
|
||||
/* NOTE: if you want this code to work on Windows with libcurl as a DLL, you
|
||||
MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
|
||||
@ -95,7 +95,7 @@ int test(char *URL)
|
||||
option you MUST make sure that the type of the passed-in argument is a
|
||||
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
|
||||
make sure that to pass in a type 'long' argument. */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
|
||||
(curl_off_t)file_info.st_size);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
@ -183,15 +183,21 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
#ifdef LIB529
|
||||
/* test 529 */
|
||||
if(m) {
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_multi_cleanup(m);
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
#else
|
||||
/* test 525 */
|
||||
if(m)
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
if(m)
|
||||
curl_multi_cleanup(m);
|
||||
#endif
|
||||
|
||||
|
@ -47,7 +47,7 @@ int test(char *URL)
|
||||
CURL *curl[NUM_HANDLES];
|
||||
int running;
|
||||
char done=FALSE;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
int current=0;
|
||||
int i, j;
|
||||
struct timeval ml_start;
|
||||
@ -72,10 +72,28 @@ int test(char *URL)
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
curl_easy_setopt(curl[i], CURLOPT_URL, URL);
|
||||
res = curl_easy_setopt(curl[i], CURLOPT_URL, URL);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_setopt() failed "
|
||||
"on handle #%d\n", i);
|
||||
for (j=i; j >= 0; j--) {
|
||||
curl_easy_cleanup(curl[j]);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
|
||||
/* go verbose */
|
||||
curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
|
||||
res = curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_setopt() failed "
|
||||
"on handle #%d\n", i);
|
||||
for (j=i; j >= 0; j--) {
|
||||
curl_easy_cleanup(curl[j]);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
@ -142,8 +160,8 @@ int test(char *URL)
|
||||
/* make us re-use the same handle all the time, and try resetting
|
||||
the handle first too */
|
||||
curl_easy_reset(curl[0]);
|
||||
curl_easy_setopt(curl[0], CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl[0], CURLOPT_URL, URL);
|
||||
test_setopt(curl[0], CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* re-add it */
|
||||
res = (int)curl_multi_add_handle(m, curl[0]);
|
||||
@ -197,15 +215,19 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
#ifndef LIB527
|
||||
/* get NUM_HANDLES easy handles */
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
#ifdef LIB526
|
||||
if(m)
|
||||
curl_multi_remove_handle(m, curl[i]);
|
||||
#endif
|
||||
curl_easy_cleanup(curl[i]);
|
||||
}
|
||||
#endif
|
||||
if(m)
|
||||
curl_multi_cleanup(m);
|
||||
|
||||
curl_global_cleanup();
|
||||
|
@ -69,13 +69,47 @@ int test(char *URL)
|
||||
}
|
||||
sprintf(target_url, "%s%04i", URL, i + 1);
|
||||
target_url[sizeof(target_url) - 1] = '\0';
|
||||
curl_easy_setopt(curl[i], CURLOPT_URL, target_url);
|
||||
|
||||
res = curl_easy_setopt(curl[i], CURLOPT_URL, target_url);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_setopt() failed "
|
||||
"on handle #%d\n", i);
|
||||
for (j=i; j >= 0; j--) {
|
||||
curl_multi_remove_handle(m, curl[j]);
|
||||
curl_easy_cleanup(curl[j]);
|
||||
}
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
|
||||
/* go verbose */
|
||||
curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
|
||||
res = curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_setopt() failed "
|
||||
"on handle #%d\n", i);
|
||||
for (j=i; j >= 0; j--) {
|
||||
curl_multi_remove_handle(m, curl[j]);
|
||||
curl_easy_cleanup(curl[j]);
|
||||
}
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
|
||||
/* include headers */
|
||||
curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L);
|
||||
res = curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L);
|
||||
if(res) {
|
||||
fprintf(stderr, "curl_easy_setopt() failed "
|
||||
"on handle #%d\n", i);
|
||||
for (j=i; j >= 0; j--) {
|
||||
curl_multi_remove_handle(m, curl[j]);
|
||||
curl_easy_cleanup(curl[j]);
|
||||
}
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD + i;
|
||||
}
|
||||
|
||||
/* add handle to multi */
|
||||
if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) {
|
||||
@ -163,6 +197,8 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* cleanup NUM_HANDLES easy handles */
|
||||
for(i=0; i < NUM_HANDLES; i++) {
|
||||
curl_multi_remove_handle(m, curl[i]);
|
||||
|
@ -28,7 +28,7 @@ int test(char *URL)
|
||||
CURL *curl;
|
||||
int running;
|
||||
char done=FALSE;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
int current=0;
|
||||
struct timeval ml_start;
|
||||
struct timeval mp_start;
|
||||
@ -46,9 +46,9 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
test_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
@ -103,9 +103,9 @@ int test(char *URL)
|
||||
/* make us re-use the same handle all the time, and try resetting
|
||||
the handle first too */
|
||||
curl_easy_reset(curl);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||
test_setopt(curl, CURLOPT_URL, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
test_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||
|
||||
/* re-add it */
|
||||
res = (int)curl_multi_add_handle(m, curl);
|
||||
@ -156,7 +156,10 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
if(m)
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -93,9 +93,9 @@ int test(char *URL)
|
||||
|
||||
curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
|
||||
|
||||
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
|
||||
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(easy, CURLOPT_URL, URL);
|
||||
test_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
|
||||
test_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
test_setopt(easy, CURLOPT_URL, URL);
|
||||
|
||||
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
|
||||
printf("curl_multi_add_handle() failed\n");
|
||||
@ -108,8 +108,8 @@ int test(char *URL)
|
||||
}
|
||||
curl_easy_reset(easy);
|
||||
|
||||
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2);
|
||||
test_setopt(easy, CURLOPT_FAILONERROR, 1L);
|
||||
test_setopt(easy, CURLOPT_URL, libtest_arg2);
|
||||
|
||||
if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
|
||||
printf("curl_multi_add_handle() 2 failed\n");
|
||||
@ -120,6 +120,9 @@ int test(char *URL)
|
||||
|
||||
curl_multi_remove_handle(multi, easy);
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
curl_multi_cleanup(multi);
|
||||
curl_global_cleanup();
|
||||
|
@ -487,11 +487,13 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
close_file_descriptors();
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -16,8 +16,8 @@ int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
char *newURL;
|
||||
struct curl_slist *slist;
|
||||
char *newURL = NULL;
|
||||
struct curl_slist *slist = NULL;
|
||||
|
||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
@ -33,9 +33,9 @@ int test(char *URL)
|
||||
/*
|
||||
* Begin with cURL set to use a single CWD to the URL's directory.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
@ -63,13 +63,16 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, newURL);
|
||||
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
|
||||
curl_easy_setopt(curl, CURLOPT_QUOTE, slist);
|
||||
test_setopt(curl, CURLOPT_URL, newURL);
|
||||
test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
|
||||
test_setopt(curl, CURLOPT_QUOTE, slist);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_slist_free_all(slist);
|
||||
if(newURL)
|
||||
free(newURL);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -24,20 +24,39 @@
|
||||
#define PROXYUSERPWD libtest_arg3
|
||||
#define HOST test_argv[4]
|
||||
|
||||
static void init(CURLM *cm, const char* url, const char* userpwd,
|
||||
static int init(CURLM *cm, const char* url, const char* userpwd,
|
||||
struct curl_slist *headers)
|
||||
{
|
||||
CURL *eh = curl_easy_init();
|
||||
CURL *eh;
|
||||
int res;
|
||||
|
||||
curl_easy_setopt(eh, CURLOPT_URL, url);
|
||||
curl_easy_setopt(eh, CURLOPT_PROXY, PROXY);
|
||||
curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd);
|
||||
curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(eh, CURLOPT_HEADER, 1L);
|
||||
curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */
|
||||
if ((eh = curl_easy_init()) == NULL) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
return 1; /* failure */
|
||||
}
|
||||
|
||||
curl_multi_add_handle(cm, eh);
|
||||
res = curl_easy_setopt(eh, CURLOPT_URL, url);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L);
|
||||
if(res) return 1;
|
||||
res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */
|
||||
if(res) return 1;
|
||||
|
||||
if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) {
|
||||
fprintf(stderr, "curl_multi_add_handle() failed, "
|
||||
"with code %d\n", res);
|
||||
return 1; /* failure */
|
||||
}
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
@ -50,7 +69,8 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
fd_set R, W, E;
|
||||
struct timeval T;
|
||||
|
||||
init(cm, url, userpwd, headers);
|
||||
if(init(cm, url, userpwd, headers))
|
||||
return 1; /* failure */
|
||||
|
||||
while (U) {
|
||||
|
||||
@ -65,7 +85,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
|
||||
if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
|
||||
fprintf(stderr, "E: curl_multi_fdset\n");
|
||||
return EXIT_FAILURE;
|
||||
return 1; /* failure */
|
||||
}
|
||||
|
||||
/* In a real-world program you OF COURSE check the return that maxfd is
|
||||
@ -73,7 +93,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
|
||||
if (curl_multi_timeout(cm, &L)) {
|
||||
fprintf(stderr, "E: curl_multi_timeout\n");
|
||||
return EXIT_FAILURE;
|
||||
return 1; /* failure */
|
||||
}
|
||||
|
||||
if(L != -1) {
|
||||
@ -87,7 +107,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
|
||||
if (0 > select(M+1, &R, &W, &E, &T)) {
|
||||
fprintf(stderr, "E: select\n");
|
||||
return EXIT_FAILURE;
|
||||
return 1; /* failure */
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,14 +125,15 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLM *cm;
|
||||
CURLM *cm = NULL;
|
||||
struct curl_slist *headers = NULL;
|
||||
char buffer[246]; /* naively fixed-size */
|
||||
int res;
|
||||
|
||||
if(test_argc < 4)
|
||||
return 99;
|
||||
@ -121,14 +142,32 @@ int test(char *URL)
|
||||
|
||||
/* now add a custom Host: header */
|
||||
headers = curl_slist_append(headers, buffer);
|
||||
if(!headers) {
|
||||
fprintf(stderr, "curl_slist_append() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
curl_slist_free_all(headers);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
cm = curl_multi_init();
|
||||
loop(cm, URL, PROXYUSERPWD, headers);
|
||||
if ((cm = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
curl_slist_free_all(headers);
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
res = loop(cm, URL, PROXYUSERPWD, headers);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
fprintf(stderr, "lib540: now we do the request again\n");
|
||||
loop(cm, URL, PROXYUSERPWD, headers);
|
||||
res = loop(cm, URL, PROXYUSERPWD, headers);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_multi_cleanup(cm);
|
||||
|
||||
@ -136,5 +175,5 @@ int test(char *URL)
|
||||
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return res;
|
||||
}
|
||||
|
@ -90,16 +90,16 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* enable uploading */
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
/* enable verbose */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, URL);
|
||||
test_setopt(curl,CURLOPT_URL, URL);
|
||||
|
||||
/* now specify which file to upload */
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, hd_src);
|
||||
test_setopt(curl, CURLOPT_INFILE, hd_src);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
@ -108,6 +108,8 @@ int test(char *URL)
|
||||
is at end of file */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* close the local file */
|
||||
fclose(hd_src);
|
||||
|
||||
|
@ -51,20 +51,22 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* enable verbose */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* enable NOBODY */
|
||||
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
test_setopt(curl, CURLOPT_NOBODY, 1L);
|
||||
|
||||
/* disable HEADER */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 0L);
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, URL);
|
||||
test_setopt(curl,CURLOPT_URL, URL);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -20,11 +20,20 @@ int test(char *URL)
|
||||
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
|
||||
0x1d, 0x57, 0xe1};
|
||||
|
||||
CURL* easy = curl_easy_init();
|
||||
int asize = (int)sizeof(a);
|
||||
char* s = curl_easy_escape(easy, (char*)a, asize);
|
||||
CURL *easy;
|
||||
int asize;
|
||||
char *s;
|
||||
(void)URL;
|
||||
|
||||
if ((easy = curl_easy_init()) == NULL) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
asize = (int)sizeof(a);
|
||||
|
||||
s = curl_easy_escape(easy, (char*)a, asize);
|
||||
|
||||
printf("%s\n", s);
|
||||
|
||||
curl_free(s);
|
||||
|
@ -40,16 +40,16 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
#ifdef LIB545
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
|
||||
#endif
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
|
||||
test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||
|
||||
/* Update the original data to detect non-copy. */
|
||||
strcpy(teststring, "FAIL");
|
||||
@ -57,6 +57,8 @@ int test(char *URL)
|
||||
/* Now, this is a POST request with binary 0 embedded in POST data. */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -84,29 +84,31 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
#ifdef LIB548
|
||||
/* set the data to POST with a mere pointer to a zero-terminated string */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
|
||||
#else
|
||||
/* 547 style, which means reading the POST data from a callback */
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
test_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -32,16 +32,19 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if(libtest_arg3)
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if(libtest_arg3) {
|
||||
/* enable ascii/text mode */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
}
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -155,48 +155,52 @@ int test(char *URL)
|
||||
|
||||
config.trace_ascii = 1; /* enable ascii tracing */
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
||||
if((curl = curl_easy_init()) == NULL) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||
test_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
||||
/* the DEBUGFUNCTION has no effect until we enable VERBOSE */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* setup repeated data string */
|
||||
for (i=0; i < sizeof(databuf); ++i)
|
||||
databuf[i] = fill[i % sizeof fill];
|
||||
|
||||
/* Post */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
|
||||
/* Setup read callback */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* Write callback */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
|
||||
/* Ioctl function */
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
|
||||
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
fprintf(stderr, "curl_easy_perform = %d\n", (int)res);
|
||||
|
||||
/* always cleanup */
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
return (int)res;
|
||||
}
|
||||
|
@ -49,42 +49,52 @@ int test(char *URL)
|
||||
int i;
|
||||
struct curl_slist *headerlist=NULL, *hl;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl = curl_easy_init();
|
||||
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
if((curl = curl_easy_init()) == NULL) {
|
||||
fprintf(stderr, "curl_easy_init() failed\n");
|
||||
curl_global_cleanup();
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
if(curl) {
|
||||
for (i = 0; i < NUM_HEADERS; i++) {
|
||||
int len = sprintf(buf, "Header%d: ", i);
|
||||
memset(&buf[len], 'A', SIZE_HEADERS);
|
||||
buf[len + SIZE_HEADERS]=0; /* zero terminate */
|
||||
hl = curl_slist_append(headerlist, buf);
|
||||
if (!hl)
|
||||
goto errout;
|
||||
goto test_cleanup;
|
||||
headerlist = hl;
|
||||
}
|
||||
|
||||
hl = curl_slist_append(headerlist, "Expect: ");
|
||||
if (!hl)
|
||||
goto errout;
|
||||
goto test_cleanup;
|
||||
headerlist = hl;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
errout:
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
curl_slist_free_all(headerlist);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
|
@ -115,29 +115,31 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* First set the URL that is about to receive our POST. */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
/* Now specify we want to POST data */
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
|
||||
/* Set the expected POST size */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
|
||||
|
||||
/* we want to use our own read function */
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
|
||||
|
||||
/* send a multi-part formpost */
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
|
||||
/* get verbose debug output please */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* include headers in the output */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -64,7 +64,7 @@ int test(char *URL)
|
||||
int res;
|
||||
CURL *curl;
|
||||
int counter=0;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
int running=1;
|
||||
struct timeval mp_start;
|
||||
char mp_timedout = FALSE;
|
||||
@ -80,26 +80,26 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
/* read the POST data from a callback */
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
|
||||
test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
|
||||
test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
|
||||
test_setopt(curl, CURLOPT_READDATA, &counter);
|
||||
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
|
||||
test_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
test_setopt(curl, CURLOPT_POST, 1L);
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
/* Convert the POST data to ASCII. */
|
||||
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
|
||||
test_setopt(curl, CURLOPT_PROXYAUTH,
|
||||
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
@ -144,10 +144,13 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_multi_cleanup(m);
|
||||
test_cleanup:
|
||||
|
||||
if(m) {
|
||||
curl_multi_remove_handle(m, curl);
|
||||
curl_multi_cleanup(m);
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
return res;
|
||||
|
@ -39,8 +39,8 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
@ -82,6 +82,7 @@ int test(char *URL)
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -23,8 +23,9 @@
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *http_handle;
|
||||
CURLM *multi_handle;
|
||||
CURLM *multi_handle = NULL;
|
||||
CURLMcode code;
|
||||
int res;
|
||||
|
||||
int still_running; /* keep number of running handles */
|
||||
|
||||
@ -33,10 +34,10 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
|
||||
/* set options */
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(http_handle, CURLOPT_HEADER, 1L);
|
||||
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
test_setopt(http_handle, CURLOPT_URL, URL);
|
||||
test_setopt(http_handle, CURLOPT_HEADER, 1L);
|
||||
test_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
test_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
|
||||
/* init a multi stack */
|
||||
multi_handle = curl_multi_init();
|
||||
@ -93,9 +94,12 @@ int test(char *URL)
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(multi_handle)
|
||||
curl_multi_cleanup(multi_handle);
|
||||
|
||||
curl_easy_cleanup(http_handle);
|
||||
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
@ -55,17 +55,19 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* enable verbose */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
/* set port number */
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) );
|
||||
test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) );
|
||||
|
||||
/* specify target */
|
||||
curl_easy_setopt(curl,CURLOPT_URL, URL);
|
||||
test_setopt(curl,CURLOPT_URL, URL);
|
||||
|
||||
/* Now run off and do what you've been told! */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -26,7 +26,7 @@ int test(char *URL)
|
||||
CURL *curl;
|
||||
int running;
|
||||
char done=FALSE;
|
||||
CURLM *m;
|
||||
CURLM *m = NULL;
|
||||
struct timeval ml_start;
|
||||
struct timeval mp_start;
|
||||
char ml_timedout = FALSE;
|
||||
@ -43,10 +43,10 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
|
||||
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||
|
||||
if ((m = curl_multi_init()) == NULL) {
|
||||
fprintf(stderr, "curl_multi_init() failed\n");
|
||||
@ -133,7 +133,10 @@ int test(char *URL)
|
||||
res = TEST_ERR_RUNS_FOREVER;
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
if(m)
|
||||
curl_multi_cleanup(m);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -30,8 +30,8 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
@ -46,6 +46,8 @@ int test(char *URL)
|
||||
}
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -32,19 +32,22 @@ int test(char *URL)
|
||||
}
|
||||
|
||||
/* Dump data to stdout for protocol verification */
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "test567");
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
test_setopt(curl, CURLOPT_USERAGENT, "test567");
|
||||
|
||||
custom_headers = curl_slist_append(custom_headers, "Test-Number: 567");
|
||||
curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(custom_headers)
|
||||
curl_slist_free_all(custom_headers);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -35,9 +35,9 @@ int test(char *URL)
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
int sdp;
|
||||
FILE *sdpf;
|
||||
FILE *sdpf = NULL;
|
||||
struct_stat file_info;
|
||||
char *stream_uri;
|
||||
char *stream_uri = NULL;
|
||||
int request=1;
|
||||
struct curl_slist *custom_headers=NULL;
|
||||
|
||||
@ -52,14 +52,18 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
sdp = open("log/file568.txt", O_RDONLY);
|
||||
fstat(sdp, &file_info);
|
||||
@ -68,65 +72,89 @@ int test(char *URL)
|
||||
sdpf = fopen("log/file568.txt", "rb");
|
||||
if(sdpf == NULL) {
|
||||
fprintf(stderr, "can't open log/file568.txt\n");
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, sdpf);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
|
||||
test_setopt(curl, CURLOPT_READDATA, sdpf);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
|
||||
|
||||
/* Do the ANNOUNCE */
|
||||
res = curl_easy_perform(curl);
|
||||
if(res) {
|
||||
fclose(sdpf);
|
||||
return res;
|
||||
}
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L);
|
||||
test_setopt(curl, CURLOPT_UPLOAD, 0L);
|
||||
fclose(sdpf);
|
||||
sdpf = NULL;
|
||||
|
||||
/* Make sure we can do a normal request now */
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
return res;
|
||||
goto test_cleanup;
|
||||
|
||||
/* Now do a POST style one */
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
custom_headers = curl_slist_append(custom_headers,
|
||||
"Content-Type: posty goodness");
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
|
||||
"postyfield=postystuff&project=curl\n");
|
||||
if(!custom_headers) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n");
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
return res;
|
||||
goto test_cleanup;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSPHEADER, NULL);
|
||||
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
|
||||
test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
|
||||
curl_slist_free_all(custom_headers);
|
||||
custom_headers = NULL;
|
||||
|
||||
/* Make sure we can do a normal request now */
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(sdpf)
|
||||
fclose(sdpf);
|
||||
|
||||
if(stream_uri)
|
||||
free(stream_uri);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
return res;
|
||||
if(custom_headers)
|
||||
curl_slist_free_all(custom_headers);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
@ -31,7 +31,7 @@ int test(char *URL)
|
||||
char *rtsp_session_id;
|
||||
int request=1;
|
||||
int i;
|
||||
FILE *idfile;
|
||||
FILE *idfile = NULL;
|
||||
|
||||
idfile = fopen(libtest_arg2, "wb");
|
||||
if(idfile == NULL) {
|
||||
@ -52,53 +52,64 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != CURLE_BAD_FUNCTION_ARGUMENT) {
|
||||
fprintf(stderr, "This should have failed. "
|
||||
"Cannot setup without a Transport: header");
|
||||
fclose(idfile);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
/* Go through the various Session IDs */
|
||||
for(i = 0; i < 3; i++) {
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
free(stream_uri);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT,
|
||||
"Fake/NotReal/JustATest;foo=baz");
|
||||
res = curl_easy_perform(curl);
|
||||
if(res) {
|
||||
fclose(idfile);
|
||||
return res;
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz");
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
|
||||
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
|
||||
rtsp_session_id = NULL;
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
|
||||
curl_easy_perform(curl);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Clear for the next go-round */
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
|
||||
test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
if(idfile)
|
||||
fclose(idfile);
|
||||
|
||||
if(stream_uri)
|
||||
free(stream_uri);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -25,7 +25,7 @@ int test(char *URL)
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
int request=1;
|
||||
char *stream_uri;
|
||||
char *stream_uri = NULL;
|
||||
|
||||
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||
fprintf(stderr, "curl_global_init() failed\n");
|
||||
@ -38,47 +38,63 @@ int test(char *URL)
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != CURLE_RTSP_CSEQ_ERROR) {
|
||||
fprintf(stderr, "Failed to detect CSeq mismatch");
|
||||
return res;
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT,
|
||||
test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
|
||||
"RAW/RAW/UDP;unicast;client_port=3056-3057");
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
return res;
|
||||
goto test_cleanup;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != CURLE_RTSP_SESSION_ERROR) {
|
||||
fprintf(stderr, "Failed to detect a Session ID mismatch");
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
|
||||
|
@ -91,7 +91,7 @@ int test(char *URL)
|
||||
{
|
||||
CURLcode res;
|
||||
CURL *curl;
|
||||
char *stream_uri;
|
||||
char *stream_uri = NULL;
|
||||
int request=1;
|
||||
FILE *protofile;
|
||||
|
||||
@ -113,54 +113,81 @@ int test(char *URL)
|
||||
fclose(protofile);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
test_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
stream_uri = NULL;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, protofile);
|
||||
test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
|
||||
test_setopt(curl, CURLOPT_TIMEOUT, 3);
|
||||
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
test_setopt(curl, CURLOPT_WRITEDATA, protofile);
|
||||
|
||||
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1");
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* This PLAY starts the interleave */
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
/* The DESCRIBE request will try to consume data after the Content */
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
if((stream_uri = suburl(URL, request++)) == NULL) {
|
||||
res = TEST_ERR_MAJOR_BAD;
|
||||
goto test_cleanup;
|
||||
}
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
stream_uri = suburl(URL, request++);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri);
|
||||
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
|
||||
free(stream_uri);
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
stream_uri = NULL;
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if(res)
|
||||
goto test_cleanup;
|
||||
|
||||
fprintf(stderr, "PLAY COMPLETE\n");
|
||||
|
||||
/* Use Receive to get the rest of the data */
|
||||
while(!res && rtp_packet_count < 13) {
|
||||
fprintf(stderr, "LOOPY LOOP!\n");
|
||||
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
|
||||
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE);
|
||||
res = curl_easy_perform(curl);
|
||||
}
|
||||
|
||||
test_cleanup:
|
||||
|
||||
fclose(protofile);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
fclose(protofile);
|
||||
|
||||
return (int)res;
|
||||
}
|
||||
|
@ -42,6 +42,9 @@
|
||||
#define TEST_ERR_MAJOR_BAD 100
|
||||
#define TEST_ERR_RUNS_FOREVER 99
|
||||
|
||||
#define test_setopt(A,B,C) \
|
||||
if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup
|
||||
|
||||
extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
|
||||
extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user