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 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00032 fprintf(stderr, "curl_global_init() failed\n");
00033 return TEST_ERR_MAJOR_BAD;
00034 }
00035
00036 curl = curl_easy_init();
00037 if(!curl) {
00038 fprintf(stderr, "curl_easy_init() failed\n");
00039 curl_global_cleanup();
00040 return TEST_ERR_MAJOR_BAD;
00041 }
00042
00043 test_setopt(curl, CURLOPT_URL, URL);
00044 test_setopt(curl, CURLOPT_HEADER, 1L);
00045 test_setopt(curl, CURLOPT_REFERER, "http://example.com/the-moo");
00046 test_setopt(curl, CURLOPT_USERAGENT, "the-moo agent next generation");
00047 test_setopt(curl, CURLOPT_COOKIE, "name=moo");
00048 test_setopt(curl, CURLOPT_VERBOSE, 1L);
00049
00050 res = curl_easy_perform(curl);
00051 if(res) {
00052 fprintf(stderr, "retrieve 1 failed\n");
00053 goto test_cleanup;
00054 }
00055
00056 curl_easy_reset(curl);
00057
00058 test_setopt(curl, CURLOPT_URL, URL);
00059 test_setopt(curl, CURLOPT_HEADER, 1L);
00060 test_setopt(curl, CURLOPT_VERBOSE, 1L);
00061
00062 res = curl_easy_perform(curl);
00063 if(res)
00064 fprintf(stderr, "retrieve 2 failed\n");
00065
00066 test_cleanup:
00067
00068 curl_easy_cleanup(curl);
00069 curl_global_cleanup();
00070
00071 return (int)res;
00072 }
00073