Loading tests/libtest/lib540.c +42 −35 Original line number Original line Diff line number Diff line Loading @@ -37,61 +37,60 @@ #define PROXYUSERPWD libtest_arg3 #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] #define HOST test_argv[4] CURL *eh = NULL; static int 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; int res; int res; if ((eh = curl_easy_init()) == NULL) { if ((eh = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n"); return 1; /* failure */ goto init_failed; } } res = curl_easy_setopt(eh, CURLOPT_URL, url); res = curl_easy_setopt(eh, CURLOPT_URL, url); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) { if ((res = (int)curl_multi_add_handle(cm, eh)) != 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", res); goto init_failed; curl_easy_cleanup(eh); return 1; /* failure */ } } return 0; /* success */ return 0; /* success */ init_failed: if(eh) { curl_easy_cleanup(eh); eh = NULL; } return 1; /* failure */ } } static int loop(CURLM *cm, const char* url, const char* userpwd, static int loop(CURLM *cm, const char* url, const char* userpwd, Loading Loading @@ -153,6 +152,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, curl_easy_strerror(msg->data.result)); curl_easy_strerror(msg->data.result)); curl_multi_remove_handle(cm, e); curl_multi_remove_handle(cm, e); curl_easy_cleanup(e); curl_easy_cleanup(e); eh = NULL; } } else { else { fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); Loading Loading @@ -204,6 +204,13 @@ int test(char *URL) test_cleanup: test_cleanup: if(cm && eh) curl_multi_remove_handle(cm, eh); if(eh) curl_easy_cleanup(eh); if(cm) curl_multi_cleanup(cm); curl_multi_cleanup(cm); curl_global_cleanup(); curl_global_cleanup(); Loading Loading
tests/libtest/lib540.c +42 −35 Original line number Original line Diff line number Diff line Loading @@ -37,61 +37,60 @@ #define PROXYUSERPWD libtest_arg3 #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] #define HOST test_argv[4] CURL *eh = NULL; static int 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; int res; int res; if ((eh = curl_easy_init()) == NULL) { if ((eh = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n"); return 1; /* failure */ goto init_failed; } } res = curl_easy_setopt(eh, CURLOPT_URL, url); res = curl_easy_setopt(eh, CURLOPT_URL, url); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ if(res) { if(res) curl_easy_cleanup(eh); goto init_failed; return 1; } if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) { if ((res = (int)curl_multi_add_handle(cm, eh)) != 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", res); goto init_failed; curl_easy_cleanup(eh); return 1; /* failure */ } } return 0; /* success */ return 0; /* success */ init_failed: if(eh) { curl_easy_cleanup(eh); eh = NULL; } return 1; /* failure */ } } static int loop(CURLM *cm, const char* url, const char* userpwd, static int loop(CURLM *cm, const char* url, const char* userpwd, Loading Loading @@ -153,6 +152,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, curl_easy_strerror(msg->data.result)); curl_easy_strerror(msg->data.result)); curl_multi_remove_handle(cm, e); curl_multi_remove_handle(cm, e); curl_easy_cleanup(e); curl_easy_cleanup(e); eh = NULL; } } else { else { fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); Loading Loading @@ -204,6 +204,13 @@ int test(char *URL) test_cleanup: test_cleanup: if(cm && eh) curl_multi_remove_handle(cm, eh); if(eh) curl_easy_cleanup(eh); if(cm) curl_multi_cleanup(cm); curl_multi_cleanup(cm); curl_global_cleanup(); curl_global_cleanup(); Loading