Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "test.h"
00023
00024 #include "memdebug.h"
00025
00026 static int progress_callback(void *clientp, double dltotal,
00027 double dlnow, double ultotal, double ulnow)
00028 {
00029 (void)clientp;
00030 (void)ulnow;
00031 (void)ultotal;
00032
00033 if((dltotal > 0.0) && (dlnow > dltotal)) {
00034
00035 printf("%.0f > %.0f !!\n", dltotal, dlnow);
00036 return -1;
00037 }
00038
00039 return 0;
00040 }
00041
00042 int test(char *URL)
00043 {
00044 CURL *curl;
00045 CURLcode res=CURLE_OK;
00046 double content_length = 0.0;
00047
00048 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00049 fprintf(stderr, "curl_global_init() failed\n");
00050 return TEST_ERR_MAJOR_BAD;
00051 }
00052
00053 curl = curl_easy_init();
00054 if(!curl) {
00055 fprintf(stderr, "curl_easy_init() failed\n");
00056 curl_global_cleanup();
00057 return TEST_ERR_MAJOR_BAD;
00058 }
00059
00060
00061 test_setopt(curl, CURLOPT_URL, URL);
00062
00063
00064 test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
00065 test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
00066
00067
00068 test_setopt(curl, CURLOPT_VERBOSE, 1L);
00069
00070
00071 test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
00072
00073
00074 test_setopt(curl, CURLOPT_HEADER, 1L);
00075
00076
00077 res = curl_easy_perform(curl);
00078
00079 if(!res) {
00080 FILE *moo;
00081 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
00082 &content_length);
00083 moo = fopen(libtest_arg2, "wb");
00084 if(moo) {
00085 fprintf(moo, "CL: %.0f\n", content_length);
00086 fclose(moo);
00087 }
00088 }
00089
00090 test_cleanup:
00091
00092
00093 curl_easy_cleanup(curl);
00094 curl_global_cleanup();
00095
00096 return res;
00097 }