1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

Addes OOM handling for curl_easy_setopt() calls in test

This commit is contained in:
Yang Tse 2010-02-05 18:07:19 +00:00
parent 12d01bc5f7
commit cad9c3f55f
50 changed files with 744 additions and 439 deletions

View File

@ -29,8 +29,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -44,6 +44,8 @@ int test(char *URL)
} }
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -30,10 +30,12 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -23,7 +23,7 @@
int test(char *URL) int test(char *URL)
{ {
CURL *c; CURL *c;
CURLM *m; CURLM *m = NULL;
int res = 0; int res = 0;
int running=1; int running=1;
struct timeval mp_start; struct timeval mp_start;
@ -40,7 +40,7 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(c, CURLOPT_URL, URL); test_setopt(c, CURLOPT_URL, URL);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n"); fprintf(stderr, "curl_multi_init() failed\n");
@ -81,9 +81,13 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
if(m) {
curl_multi_remove_handle(m, c); curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m); curl_multi_cleanup(m);
}
curl_easy_cleanup(c);
curl_global_cleanup(); curl_global_cleanup();
return res; return res;

View File

@ -29,7 +29,7 @@
int test(char *URL) int test(char *URL)
{ {
CURL *c; CURL *c;
CURLM *m; CURLM *m = NULL;
int res = 0; int res = 0;
int running; int running;
char done = FALSE; char done = FALSE;
@ -49,12 +49,12 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ test_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
curl_easy_setopt(c, CURLOPT_URL, URL); test_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); test_setopt(c, CURLOPT_USERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); test_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); test_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
curl_easy_setopt(c, CURLOPT_HEADER, 1L); test_setopt(c, CURLOPT_HEADER, 1L);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n"); fprintf(stderr, "curl_multi_init() failed\n");
@ -139,9 +139,13 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
if(m) {
curl_multi_remove_handle(m, c); curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m); curl_multi_cleanup(m);
}
curl_easy_cleanup(c);
curl_global_cleanup(); curl_global_cleanup();
return res; return res;

View File

@ -28,10 +28,10 @@
int test(char *URL) int test(char *URL)
{ {
CURL *c; CURL *c;
int ret=0; int res = 0;
CURLM *m; CURLM *m = NULL;
fd_set rd, wr, exc; fd_set rd, wr, exc;
CURLMcode res; CURLMcode ret;
char done = FALSE; char done = FALSE;
int running; int running;
int max_fd; int max_fd;
@ -54,9 +54,9 @@ int test(char *URL)
/* the point here being that there must not run anything on the given /* the point here being that there must not run anything on the given
proxy port */ proxy port */
curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); test_setopt(c, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(c, CURLOPT_URL, URL); test_setopt(c, CURLOPT_URL, URL);
curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); test_setopt(c, CURLOPT_VERBOSE, 1L);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n"); fprintf(stderr, "curl_multi_init() failed\n");
@ -65,9 +65,9 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; 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, " fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res); "with code %d\n", ret);
curl_multi_cleanup(m); curl_multi_cleanup(m);
curl_easy_cleanup(c); curl_easy_cleanup(c);
curl_global_cleanup(); curl_global_cleanup();
@ -93,10 +93,10 @@ int test(char *URL)
fprintf(stderr, "curl_multi_perform()\n"); fprintf(stderr, "curl_multi_perform()\n");
res = CURLM_CALL_MULTI_PERFORM; ret = CURLM_CALL_MULTI_PERFORM;
while (res == CURLM_CALL_MULTI_PERFORM) { while (ret == CURLM_CALL_MULTI_PERFORM) {
res = curl_multi_perform(m, &running); ret = curl_multi_perform(m, &running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) > if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) { MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE; mp_timedout = TRUE;
@ -112,15 +112,15 @@ int test(char *URL)
CURLMsg *msg = curl_multi_info_read(m, &numleft); CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Expected: not running\n"); fprintf(stderr, "Expected: not running\n");
if(msg && !numleft) if(msg && !numleft)
ret = 100; /* this is where we should be */ res = 100; /* this is where we should be */
else else
ret = 99; /* not correct */ res = 99; /* not correct */
break; break;
} }
fprintf(stderr, "running == %d, res == %d\n", running, res); fprintf(stderr, "running == %d, ret == %d\n", running, ret);
if (res != CURLM_OK) { if (ret != CURLM_OK) {
ret = 2; res = 2;
break; break;
} }
@ -132,7 +132,7 @@ int test(char *URL)
fprintf(stderr, "curl_multi_fdset()\n"); fprintf(stderr, "curl_multi_fdset()\n");
if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
fprintf(stderr, "unexpected failured of fdset.\n"); fprintf(stderr, "unexpected failured of fdset.\n");
ret = 3; res = 3;
break; break;
} }
rc = select_test(max_fd+1, &rd, &wr, &exc, &interval); 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"); if (mp_timedout) fprintf(stderr, "mp_timedout\n");
fprintf(stderr, "ABORTING TEST, since it seems " fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n"); "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_multi_remove_handle(m, c);
curl_easy_cleanup(c);
curl_multi_cleanup(m); curl_multi_cleanup(m);
}
curl_easy_cleanup(c);
curl_global_cleanup(); curl_global_cleanup();
return ret; return res;
} }

View File

@ -117,27 +117,29 @@ int test(char *URL)
headerlist = hl; headerlist = hl;
/* enable uploading */ /* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */ /* enable verbose */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */ /* 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 */ /* 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 */ /* 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) */ /* 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); (curl_off_t)file_info.st_size);
/* Now run off and do what you've been told! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* clean up the FTP commands list */ /* clean up the FTP commands list */
curl_slist_free_all(headerlist); curl_slist_free_all(headerlist);

View File

@ -224,12 +224,12 @@ int test(char *URL)
url = suburl( URL, i ); url = suburl( URL, i );
headers = sethost( NULL ); headers = sethost( NULL );
curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers ); test_setopt( curl, CURLOPT_HTTPHEADER, headers );
curl_easy_setopt( curl, CURLOPT_URL, url ); test_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" ); printf( "CURLOPT_SHARE\n" );
curl_easy_setopt( curl, CURLOPT_SHARE, share ); test_setopt( curl, CURLOPT_SHARE, share );
printf( "CURLOPT_COOKIEJAR\n" ); printf( "CURLOPT_COOKIEJAR\n" );
curl_easy_setopt( curl, CURLOPT_COOKIEJAR, JAR ); test_setopt( curl, CURLOPT_COOKIEJAR, JAR );
printf( "PERFORM\n" ); printf( "PERFORM\n" );
curl_easy_perform( curl ); curl_easy_perform( curl );
@ -245,6 +245,8 @@ int test(char *URL)
printf( "SHARE_CLEANUP failed, correct\n" ); printf( "SHARE_CLEANUP failed, correct\n" );
} }
test_cleanup:
/* clean up last handle */ /* clean up last handle */
printf( "CLEANUP\n" ); printf( "CLEANUP\n" );
curl_easy_cleanup( curl ); curl_easy_cleanup( curl );

View File

@ -22,8 +22,9 @@ int test(char *URL)
CURLM* multi; CURLM* multi;
int still_running; int still_running;
int i = -1; int i = -1;
int res = 0;
CURLMsg *msg; CURLMsg *msg;
CURLMcode res; CURLMcode ret;
struct timeval ml_start; struct timeval ml_start;
struct timeval mp_start; struct timeval mp_start;
char ml_timedout = FALSE; char ml_timedout = FALSE;
@ -47,11 +48,11 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; 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, " fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res); "with code %d\n", ret);
curl_easy_cleanup(curls); curl_easy_cleanup(curls);
curl_multi_cleanup(multi); curl_multi_cleanup(multi);
curl_global_cleanup(); curl_global_cleanup();
@ -62,13 +63,13 @@ int test(char *URL)
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
do { do {
res = curl_multi_perform(multi, &still_running); ret = curl_multi_perform(multi, &still_running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) > if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) { MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE; mp_timedout = TRUE;
break; break;
} }
} while (res == CURLM_CALL_MULTI_PERFORM); } while (ret == CURLM_CALL_MULTI_PERFORM);
ml_timedout = FALSE; ml_timedout = FALSE;
ml_start = tutil_tvnow(); ml_start = tutil_tvnow();
@ -103,13 +104,13 @@ int test(char *URL)
mp_timedout = FALSE; mp_timedout = FALSE;
mp_start = tutil_tvnow(); mp_start = tutil_tvnow();
do { do {
res = curl_multi_perform(multi, &still_running); ret = curl_multi_perform(multi, &still_running);
if (tutil_tvdiff(tutil_tvnow(), mp_start) > if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) { MULTI_PERFORM_HANG_TIMEOUT) {
mp_timedout = TRUE; mp_timedout = TRUE;
break; break;
} }
} while (res == CURLM_CALL_MULTI_PERFORM); } while (ret == CURLM_CALL_MULTI_PERFORM);
break; break;
} }
} }
@ -128,9 +129,14 @@ int test(char *URL)
i = msg->data.result; i = msg->data.result;
} }
test_cleanup:
curl_multi_cleanup(multi); curl_multi_cleanup(multi);
curl_easy_cleanup(curls); curl_easy_cleanup(curls);
curl_global_cleanup(); curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */ return i; /* return the final return code */
} }

View File

@ -58,34 +58,36 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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 */ /* Now specify we want to POST data */
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS #ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */ /* Convert the POST data to ASCII */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif #endif
/* Set the expected POST size */ /* 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 */ /* 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 */ /* 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 */ /* get verbose debug output please */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */ /* 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 */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -72,39 +72,41 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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 */ /* Now specify we want to POST data */
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS #ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */ /* Convert the POST data to ASCII */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif #endif
/* we want to use our own read function */ /* 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 */ /* 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 */ /* get verbose debug output please */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */ /* 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 */ /* enforce chunked transfer by setting the header */
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); test_setopt(curl, CURLOPT_HTTPHEADER, slist);
#ifdef LIB565 #ifdef LIB565
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_USERPWD, "foo:bar"); test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
#endif #endif
/* Perform the request, res will get the return code */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* clean up the headers list */ /* clean up the headers list */
if(slist) if(slist)
curl_slist_free_all(slist); curl_slist_free_all(slist);

View File

@ -28,13 +28,15 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); test_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); test_setopt(curl, CURLOPT_NOBODY, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -38,29 +38,31 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* get verbose debug output please */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */ /* 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 */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -29,7 +29,7 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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: /* 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"); test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L); test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
/* this is where transfer 1 would take place, but skip that and change /* this is where transfer 1 would take place, but skip that and change
options right away instead */ 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 */ test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a fine HEAD request */ /* Now, we should be making a fine HEAD request */
/* Perform the request 2, res will get the return code */ /* Perform the request 2, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -29,15 +29,17 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* First set the URL that is about to receive our POST. */
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L); test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a zero byte POST request */ /* Now, we should be making a zero byte POST request */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -29,14 +29,16 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* First set the URL that is about to receive our POST. */
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); test_setopt(curl, CURLOPT_HTTPPOST, NULL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a zero byte POST request */ /* Now, we should be making a zero byte POST request */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -484,11 +484,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
close_file_descriptors(); close_file_descriptors();
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -28,19 +28,21 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); test_setopt(curl, CURLOPT_USERPWD, "monster:underbed");
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* get first page */ /* get first page */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe"); test_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe");
/* get second page */ /* get second page */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -28,12 +28,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); test_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -28,13 +28,15 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2));
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -28,14 +28,16 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
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);
curl_easy_setopt(curl, CURLOPT_PORT, 19999L); test_setopt(curl, CURLOPT_PORT, 19999L);
curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -28,12 +28,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -30,7 +30,7 @@ int test(char *URL)
struct_stat file_info; struct_stat file_info;
int running; int running;
char done=FALSE; char done=FALSE;
CURLM *m; CURLM *m = NULL;
struct timeval ml_start; struct timeval ml_start;
struct timeval mp_start; struct timeval mp_start;
char ml_timedout = FALSE; char ml_timedout = FALSE;
@ -72,19 +72,19 @@ int test(char *URL)
} }
/* enable uploading */ /* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */ /* specify target */
curl_easy_setopt(curl,CURLOPT_URL, URL); test_setopt(curl,CURLOPT_URL, URL);
/* go verbose */ /* go verbose */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* use active FTP */ /* use active FTP */
curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); test_setopt(curl, CURLOPT_FTPPORT, "-");
/* now specify which file to upload */ /* 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 /* 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 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 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 curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
make sure that to pass in a type 'long' argument. */ 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); (curl_off_t)file_info.st_size);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
@ -183,15 +183,21 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
#ifdef LIB529 #ifdef LIB529
/* test 529 */ /* test 529 */
if(m) {
curl_multi_remove_handle(m, curl); curl_multi_remove_handle(m, curl);
curl_multi_cleanup(m); curl_multi_cleanup(m);
}
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
#else #else
/* test 525 */ /* test 525 */
if(m)
curl_multi_remove_handle(m, curl); curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
if(m)
curl_multi_cleanup(m); curl_multi_cleanup(m);
#endif #endif

View File

@ -47,7 +47,7 @@ int test(char *URL)
CURL *curl[NUM_HANDLES]; CURL *curl[NUM_HANDLES];
int running; int running;
char done=FALSE; char done=FALSE;
CURLM *m; CURLM *m = NULL;
int current=0; int current=0;
int i, j; int i, j;
struct timeval ml_start; struct timeval ml_start;
@ -72,10 +72,28 @@ int test(char *URL)
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD + i; 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 */ /* 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) { 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 /* make us re-use the same handle all the time, and try resetting
the handle first too */ the handle first too */
curl_easy_reset(curl[0]); curl_easy_reset(curl[0]);
curl_easy_setopt(curl[0], CURLOPT_URL, URL); test_setopt(curl[0], CURLOPT_URL, URL);
curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1L); test_setopt(curl[0], CURLOPT_VERBOSE, 1L);
/* re-add it */ /* re-add it */
res = (int)curl_multi_add_handle(m, curl[0]); res = (int)curl_multi_add_handle(m, curl[0]);
@ -197,15 +215,19 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
#ifndef LIB527 #ifndef LIB527
/* get NUM_HANDLES easy handles */ /* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) { for(i=0; i < NUM_HANDLES; i++) {
#ifdef LIB526 #ifdef LIB526
if(m)
curl_multi_remove_handle(m, curl[i]); curl_multi_remove_handle(m, curl[i]);
#endif #endif
curl_easy_cleanup(curl[i]); curl_easy_cleanup(curl[i]);
} }
#endif #endif
if(m)
curl_multi_cleanup(m); curl_multi_cleanup(m);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -69,13 +69,47 @@ int test(char *URL)
} }
sprintf(target_url, "%s%04i", URL, i + 1); sprintf(target_url, "%s%04i", URL, i + 1);
target_url[sizeof(target_url) - 1] = '\0'; 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 */ /* 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 */ /* 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 */ /* add handle to multi */
if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) { 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; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
/* cleanup NUM_HANDLES easy handles */ /* cleanup NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) { for(i=0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]); curl_multi_remove_handle(m, curl[i]);

View File

@ -28,7 +28,7 @@ int test(char *URL)
CURL *curl; CURL *curl;
int running; int running;
char done=FALSE; char done=FALSE;
CURLM *m; CURLM *m = NULL;
int current=0; int current=0;
struct timeval ml_start; struct timeval ml_start;
struct timeval mp_start; struct timeval mp_start;
@ -46,9 +46,9 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); test_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); test_setopt(curl, CURLOPT_FAILONERROR, 1);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n"); 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 /* make us re-use the same handle all the time, and try resetting
the handle first too */ the handle first too */
curl_easy_reset(curl); curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2); test_setopt(curl, CURLOPT_URL, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); test_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); test_setopt(curl, CURLOPT_FAILONERROR, 1);
/* re-add it */ /* re-add it */
res = (int)curl_multi_add_handle(m, curl); res = (int)curl_multi_add_handle(m, curl);
@ -156,7 +156,10 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
if(m)
curl_multi_cleanup(m); curl_multi_cleanup(m);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -93,9 +93,9 @@ int test(char *URL)
curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L); curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); test_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); test_setopt(easy, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(easy, CURLOPT_URL, URL); test_setopt(easy, CURLOPT_URL, URL);
if (curl_multi_add_handle(multi, easy) != CURLM_OK) { if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
printf("curl_multi_add_handle() failed\n"); printf("curl_multi_add_handle() failed\n");
@ -108,8 +108,8 @@ int test(char *URL)
} }
curl_easy_reset(easy); curl_easy_reset(easy);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); test_setopt(easy, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2); test_setopt(easy, CURLOPT_URL, libtest_arg2);
if (curl_multi_add_handle(multi, easy) != CURLM_OK) { if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
printf("curl_multi_add_handle() 2 failed\n"); printf("curl_multi_add_handle() 2 failed\n");
@ -120,6 +120,9 @@ int test(char *URL)
curl_multi_remove_handle(multi, easy); curl_multi_remove_handle(multi, easy);
} }
test_cleanup:
curl_easy_cleanup(easy); curl_easy_cleanup(easy);
curl_multi_cleanup(multi); curl_multi_cleanup(multi);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -487,11 +487,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
close_file_descriptors(); close_file_descriptors();
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -16,8 +16,8 @@ int test(char *URL)
{ {
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
char *newURL; char *newURL = NULL;
struct curl_slist *slist; struct curl_slist *slist = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); 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. * Begin with cURL set to use a single CWD to the URL's directory.
*/ */
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -63,13 +63,16 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_URL, newURL);
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
curl_easy_setopt(curl, CURLOPT_QUOTE, slist); test_setopt(curl, CURLOPT_QUOTE, slist);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(slist); curl_slist_free_all(slist);
if(newURL)
free(newURL); free(newURL);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -24,20 +24,39 @@
#define PROXYUSERPWD libtest_arg3 #define PROXYUSERPWD libtest_arg3
#define HOST test_argv[4] #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) struct curl_slist *headers)
{ {
CURL *eh = curl_easy_init(); CURL *eh;
int res;
curl_easy_setopt(eh, CURLOPT_URL, url); if ((eh = curl_easy_init()) == NULL) {
curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); fprintf(stderr, "curl_easy_init() failed\n");
curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); return 1; /* failure */
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: */
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, 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; fd_set R, W, E;
struct timeval T; struct timeval T;
init(cm, url, userpwd, headers); if(init(cm, url, userpwd, headers))
return 1; /* failure */
while (U) { 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)) { if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
fprintf(stderr, "E: curl_multi_fdset\n"); 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 /* 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)) { if (curl_multi_timeout(cm, &L)) {
fprintf(stderr, "E: curl_multi_timeout\n"); fprintf(stderr, "E: curl_multi_timeout\n");
return EXIT_FAILURE; return 1; /* failure */
} }
if(L != -1) { 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)) { if (0 > select(M+1, &R, &W, &E, &T)) {
fprintf(stderr, "E: select\n"); 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) int test(char *URL)
{ {
CURLM *cm; CURLM *cm = NULL;
struct curl_slist *headers = NULL; struct curl_slist *headers = NULL;
char buffer[246]; /* naively fixed-size */ char buffer[246]; /* naively fixed-size */
int res;
if(test_argc < 4) if(test_argc < 4)
return 99; return 99;
@ -121,14 +142,32 @@ int test(char *URL)
/* now add a custom Host: header */ /* now add a custom Host: header */
headers = curl_slist_append(headers, buffer); 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(); if ((cm = curl_multi_init()) == NULL) {
loop(cm, URL, PROXYUSERPWD, headers); 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"); 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); curl_multi_cleanup(cm);
@ -136,5 +175,5 @@ int test(char *URL)
curl_slist_free_all(headers); curl_slist_free_all(headers);
return EXIT_SUCCESS; return res;
} }

View File

@ -90,16 +90,16 @@ int test(char *URL)
} }
/* enable uploading */ /* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* enable verbose */ /* enable verbose */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */ /* specify target */
curl_easy_setopt(curl,CURLOPT_URL, URL); test_setopt(curl,CURLOPT_URL, URL);
/* now specify which file to upload */ /* 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! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -108,6 +108,8 @@ int test(char *URL)
is at end of file */ is at end of file */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* close the local file */ /* close the local file */
fclose(hd_src); fclose(hd_src);

View File

@ -51,20 +51,22 @@ int test(char *URL)
} }
/* enable verbose */ /* enable verbose */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* enable NOBODY */ /* enable NOBODY */
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); test_setopt(curl, CURLOPT_NOBODY, 1L);
/* disable HEADER */ /* disable HEADER */
curl_easy_setopt(curl, CURLOPT_HEADER, 0L); test_setopt(curl, CURLOPT_HEADER, 0L);
/* specify target */ /* 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! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -20,11 +20,20 @@ int test(char *URL)
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa, 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
0x1d, 0x57, 0xe1}; 0x1d, 0x57, 0xe1};
CURL* easy = curl_easy_init(); CURL *easy;
int asize = (int)sizeof(a); int asize;
char* s = curl_easy_escape(easy, (char*)a, asize); char *s;
(void)URL; (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); printf("%s\n", s);
curl_free(s); curl_free(s);

View File

@ -40,16 +40,16 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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 #ifdef LIB545
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1); test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
#endif #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 */ test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Update the original data to detect non-copy. */ /* Update the original data to detect non-copy. */
strcpy(teststring, "FAIL"); strcpy(teststring, "FAIL");
@ -57,6 +57,8 @@ int test(char *URL)
/* Now, this is a POST request with binary 0 embedded in POST data. */ /* Now, this is a POST request with binary 0 embedded in POST data. */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -84,29 +84,31 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
#ifdef LIB548 #ifdef LIB548
/* set the data to POST with a mere pointer to a zero-terminated string */ /* 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 #else
/* 547 style, which means reading the POST data from a callback */ /* 547 style, which means reading the POST data from a callback */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
curl_easy_setopt(curl, CURLOPT_READDATA, &counter); test_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */ /* 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 #endif
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, test_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -32,16 +32,19 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
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);
curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); test_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
if(libtest_arg3) if(libtest_arg3) {
/* enable ascii/text mode */ /* enable ascii/text mode */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
}
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -155,48 +155,52 @@ int test(char *URL)
config.trace_ascii = 1; /* enable ascii tracing */ config.trace_ascii = 1; /* enable ascii tracing */
curl = curl_easy_init(); if((curl = curl_easy_init()) == NULL) {
if(curl) { fprintf(stderr, "curl_easy_init() failed\n");
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); curl_global_cleanup();
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); 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 */ /* 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 */ /* setup repeated data string */
for (i=0; i < sizeof(databuf); ++i) for (i=0; i < sizeof(databuf); ++i)
databuf[i] = fill[i % sizeof fill]; databuf[i] = fill[i % sizeof fill];
/* Post */ /* Post */
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS #ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */ /* Convert the POST data to ASCII */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif #endif
/* Setup read callback */ /* Setup read callback */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* Write callback */ /* Write callback */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
/* Ioctl function */ /* 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 */ /* 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); res = curl_easy_perform(curl);
fprintf(stderr, "curl_easy_perform = %d\n", (int)res); fprintf(stderr, "curl_easy_perform = %d\n", (int)res);
/* always cleanup */ test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
}
curl_global_cleanup(); curl_global_cleanup();
return (int)res; return (int)res;
} }

View File

@ -49,42 +49,52 @@ int test(char *URL)
int i; int i;
struct curl_slist *headerlist=NULL, *hl; struct curl_slist *headerlist=NULL, *hl;
curl_global_init(CURL_GLOBAL_ALL); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl = curl_easy_init(); 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++) { for (i = 0; i < NUM_HEADERS; i++) {
int len = sprintf(buf, "Header%d: ", i); int len = sprintf(buf, "Header%d: ", i);
memset(&buf[len], 'A', SIZE_HEADERS); memset(&buf[len], 'A', SIZE_HEADERS);
buf[len + SIZE_HEADERS]=0; /* zero terminate */ buf[len + SIZE_HEADERS]=0; /* zero terminate */
hl = curl_slist_append(headerlist, buf); hl = curl_slist_append(headerlist, buf);
if (!hl) if (!hl)
goto errout; goto test_cleanup;
headerlist = hl; headerlist = hl;
} }
hl = curl_slist_append(headerlist, "Expect: "); hl = curl_slist_append(headerlist, "Expect: ");
if (!hl) if (!hl)
goto errout; goto test_cleanup;
headerlist = hl; headerlist = hl;
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); test_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS #ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */ /* Convert the POST data to ASCII */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif #endif
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
errout: test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_slist_free_all(headerlist); curl_slist_free_all(headerlist);
}
curl_global_cleanup(); curl_global_cleanup();
return (int)res; return (int)res;

View File

@ -115,29 +115,31 @@ int test(char *URL)
} }
/* First set the URL that is about to receive our POST. */ /* 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 */ /* 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 */ /* 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 */ /* 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 */ /* send a multi-part formpost */
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); test_setopt(curl, CURLOPT_HTTPPOST, formpost);
/* get verbose debug output please */ /* get verbose debug output please */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */ /* 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 */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */ /* always cleanup */
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -64,7 +64,7 @@ int test(char *URL)
int res; int res;
CURL *curl; CURL *curl;
int counter=0; int counter=0;
CURLM *m; CURLM *m = NULL;
int running=1; int running=1;
struct timeval mp_start; struct timeval mp_start;
char mp_timedout = FALSE; char mp_timedout = FALSE;
@ -80,26 +80,26 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
/* read the POST data from a callback */ /* read the POST data from a callback */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
curl_easy_setopt(curl, CURLOPT_READDATA, &counter); test_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */ /* 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 #ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII. */ /* Convert the POST data to ASCII. */
curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif #endif
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, test_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
@ -144,10 +144,13 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
curl_multi_remove_handle(m, curl); test_cleanup:
curl_easy_cleanup(curl);
curl_multi_cleanup(m);
if(m) {
curl_multi_remove_handle(m, curl);
curl_multi_cleanup(m);
}
curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();
return res; return res;

View File

@ -39,8 +39,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -82,6 +82,7 @@ int test(char *URL)
} }
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -23,8 +23,9 @@
int test(char *URL) int test(char *URL)
{ {
CURL *http_handle; CURL *http_handle;
CURLM *multi_handle; CURLM *multi_handle = NULL;
CURLMcode code; CURLMcode code;
int res;
int still_running; /* keep number of running handles */ int still_running; /* keep number of running handles */
@ -33,10 +34,10 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
/* set options */ /* set options */
curl_easy_setopt(http_handle, CURLOPT_URL, URL); test_setopt(http_handle, CURLOPT_URL, URL);
curl_easy_setopt(http_handle, CURLOPT_HEADER, 1L); test_setopt(http_handle, CURLOPT_HEADER, 1L);
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L); test_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L); test_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
/* init a multi stack */ /* init a multi stack */
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
@ -93,9 +94,12 @@ int test(char *URL)
} }
} }
test_cleanup:
if(multi_handle)
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle); curl_easy_cleanup(http_handle);
return 0; return res;
} }

View File

@ -55,17 +55,19 @@ int test(char *URL)
} }
/* enable verbose */ /* enable verbose */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set port number */ /* set port number */
curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) );
/* specify target */ /* 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! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -26,7 +26,7 @@ int test(char *URL)
CURL *curl; CURL *curl;
int running; int running;
char done=FALSE; char done=FALSE;
CURLM *m; CURLM *m = NULL;
struct timeval ml_start; struct timeval ml_start;
struct timeval mp_start; struct timeval mp_start;
char ml_timedout = FALSE; char ml_timedout = FALSE;
@ -43,10 +43,10 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); test_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
if ((m = curl_multi_init()) == NULL) { if ((m = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n"); fprintf(stderr, "curl_multi_init() failed\n");
@ -133,7 +133,10 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER; res = TEST_ERR_RUNS_FOREVER;
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
if(m)
curl_multi_cleanup(m); curl_multi_cleanup(m);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -30,8 +30,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
@ -46,6 +46,8 @@ int test(char *URL)
} }
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -32,19 +32,22 @@ int test(char *URL)
} }
/* Dump data to stdout for protocol verification */ /* Dump data to stdout for protocol verification */
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); test_setopt(curl, CURLOPT_HEADERDATA, stdout);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); test_setopt(curl, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL);
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "test567"); test_setopt(curl, CURLOPT_USERAGENT, "test567");
custom_headers = curl_slist_append(custom_headers, "Test-Number: 567"); 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); res = curl_easy_perform(curl);
test_cleanup:
if(custom_headers)
curl_slist_free_all(custom_headers); curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -35,9 +35,9 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
int sdp; int sdp;
FILE *sdpf; FILE *sdpf = NULL;
struct_stat file_info; struct_stat file_info;
char *stream_uri; char *stream_uri = NULL;
int request=1; int request=1;
struct curl_slist *custom_headers=NULL; struct curl_slist *custom_headers=NULL;
@ -52,14 +52,18 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); test_setopt(curl, CURLOPT_HEADERDATA, stdout);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, 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++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
sdp = open("log/file568.txt", O_RDONLY); sdp = open("log/file568.txt", O_RDONLY);
fstat(sdp, &file_info); fstat(sdp, &file_info);
@ -68,65 +72,89 @@ int test(char *URL)
sdpf = fopen("log/file568.txt", "rb"); sdpf = fopen("log/file568.txt", "rb");
if(sdpf == NULL) { if(sdpf == NULL) {
fprintf(stderr, "can't open log/file568.txt\n"); 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); test_setopt(curl, CURLOPT_READDATA, sdpf);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
/* Do the ANNOUNCE */ /* Do the ANNOUNCE */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res) { if(res)
fclose(sdpf); goto test_cleanup;
return res;
}
curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L); test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(sdpf); fclose(sdpf);
sdpf = NULL;
/* Make sure we can do a normal request now */ /* Make sure we can do a normal request now */
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(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); res = curl_easy_perform(curl);
if(res) if(res)
return res; goto test_cleanup;
/* Now do a POST style one */ /* Now do a POST style one */
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
custom_headers = curl_slist_append(custom_headers, custom_headers = curl_slist_append(custom_headers,
"Content-Type: posty goodness"); "Content-Type: posty goodness");
if(!custom_headers) {
curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); res = TEST_ERR_MAJOR_BAD;
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); goto test_cleanup;
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, }
"postyfield=postystuff&project=curl\n"); 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); res = curl_easy_perform(curl);
if(res) if(res)
return res; goto test_cleanup;
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curl, CURLOPT_RTSPHEADER, NULL); test_setopt(curl, CURLOPT_RTSPHEADER, NULL);
curl_slist_free_all(custom_headers); curl_slist_free_all(custom_headers);
custom_headers = NULL;
/* Make sure we can do a normal request now */ /* Make sure we can do a normal request now */
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); 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); free(stream_uri);
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); if(custom_headers)
res = curl_easy_perform(curl); curl_slist_free_all(custom_headers);
if(res)
return res;
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -31,7 +31,7 @@ int test(char *URL)
char *rtsp_session_id; char *rtsp_session_id;
int request=1; int request=1;
int i; int i;
FILE *idfile; FILE *idfile = NULL;
idfile = fopen(libtest_arg2, "wb"); idfile = fopen(libtest_arg2, "wb");
if(idfile == NULL) { if(idfile == NULL) {
@ -52,53 +52,64 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); test_setopt(curl, CURLOPT_HEADERDATA, stdout);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); test_setopt(curl, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); 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); res = curl_easy_perform(curl);
if(res != CURLE_BAD_FUNCTION_ARGUMENT) { if(res != CURLE_BAD_FUNCTION_ARGUMENT) {
fprintf(stderr, "This should have failed. " fprintf(stderr, "This should have failed. "
"Cannot setup without a Transport: header"); "Cannot setup without a Transport: header");
fclose(idfile); res = TEST_ERR_MAJOR_BAD;
return TEST_ERR_MAJOR_BAD; goto test_cleanup;
} }
/* Go through the various Session IDs */ /* Go through the various Session IDs */
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
free(stream_uri); goto test_cleanup;
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;
} }
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); curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id);
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
rtsp_session_id = NULL; rtsp_session_id = NULL;
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
curl_easy_perform(curl); res = curl_easy_perform(curl);
/* Clear for the next go-round */ /* 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); fclose(idfile);
if(stream_uri)
free(stream_uri);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -25,7 +25,7 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
int request=1; int request=1;
char *stream_uri; char *stream_uri = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
@ -38,47 +38,63 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); test_setopt(curl, CURLOPT_HEADERDATA, stdout);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); test_setopt(curl, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); 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++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res != CURLE_RTSP_CSEQ_ERROR) { if(res != CURLE_RTSP_CSEQ_ERROR) {
fprintf(stderr, "Failed to detect CSeq mismatch"); 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); test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999);
curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
"RAW/RAW/UDP;unicast;client_port=3056-3057"); "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++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res) if(res)
return res; goto test_cleanup;
curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
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); free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res != CURLE_RTSP_SESSION_ERROR) { if(res != CURLE_RTSP_SESSION_ERROR) {
fprintf(stderr, "Failed to detect a Session ID mismatch"); fprintf(stderr, "Failed to detect a Session ID mismatch");
} }
test_cleanup:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -91,7 +91,7 @@ int test(char *URL)
{ {
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
char *stream_uri; char *stream_uri = NULL;
int request=1; int request=1;
FILE *protofile; FILE *protofile;
@ -113,54 +113,81 @@ int test(char *URL)
fclose(protofile); fclose(protofile);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
curl_easy_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri); free(stream_uri);
stream_uri = NULL;
curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3); test_setopt(curl, CURLOPT_TIMEOUT, 3);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, protofile); 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); res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* This PLAY starts the interleave */ /* This PLAY starts the interleave */
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(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); res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* The DESCRIBE request will try to consume data after the Content */ /* The DESCRIBE request will try to consume data after the Content */
stream_uri = suburl(URL, request++); if((stream_uri = suburl(URL, request++)) == NULL) {
curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(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); res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
stream_uri = suburl(URL, request++); 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); 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); res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
fprintf(stderr, "PLAY COMPLETE\n"); fprintf(stderr, "PLAY COMPLETE\n");
/* Use Receive to get the rest of the data */ /* Use Receive to get the rest of the data */
while(!res && rtp_packet_count < 13) { while(!res && rtp_packet_count < 13) {
fprintf(stderr, "LOOPY LOOP!\n"); 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); res = curl_easy_perform(curl);
} }
test_cleanup:
fclose(protofile);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();
fclose(protofile);
return (int)res; return (int)res;
} }

View File

@ -42,6 +42,9 @@
#define TEST_ERR_MAJOR_BAD 100 #define TEST_ERR_MAJOR_BAD 100
#define TEST_ERR_RUNS_FOREVER 99 #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_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 */ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */