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 int test(char *URL)
00027 {
00028 CURLcode res;
00029 CURL *curl;
00030
00031 double content_length = 3;
00032
00033 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00034 fprintf(stderr, "curl_global_init() failed\n");
00035 return TEST_ERR_MAJOR_BAD;
00036 }
00037
00038 curl = curl_easy_init();
00039 if(!curl) {
00040 fprintf(stderr, "curl_easy_init() failed\n");
00041 curl_global_cleanup();
00042 return TEST_ERR_MAJOR_BAD;
00043 }
00044
00045 test_setopt(curl, CURLOPT_URL, URL);
00046 test_setopt(curl, CURLOPT_HEADER, 1L);
00047
00048 res = curl_easy_perform(curl);
00049
00050 if(!res) {
00051 FILE *moo;
00052 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
00053 &content_length);
00054 moo = fopen(libtest_arg2, "wb");
00055 if(moo) {
00056 fprintf(moo, "CL: %.0f\n", content_length);
00057 fclose(moo);
00058 }
00059 }
00060
00061 test_cleanup:
00062
00063 curl_easy_cleanup(curl);
00064 curl_global_cleanup();
00065
00066 return (int)res;
00067 }
00068