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
00023
00024
00025
00026
00027
00028
00029 #include "test.h"
00030
00031 #include "memdebug.h"
00032
00033 #define NUM_HANDLES 2
00034
00035 int test(char *URL)
00036 {
00037 int res = 0;
00038 CURL *curl[NUM_HANDLES] = {NULL, NULL};
00039 char *port = libtest_arg3;
00040 char *address = libtest_arg2;
00041 char dnsentry[256];
00042 struct curl_slist *slist = NULL;
00043 int i;
00044 char target_url[256];
00045 (void)URL;
00046
00047 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00048 fprintf(stderr, "curl_global_init() failed\n");
00049 return TEST_ERR_MAJOR_BAD;
00050 }
00051
00052 snprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s",
00053 port, address);
00054 printf("%s\n", dnsentry);
00055 slist = curl_slist_append(slist, dnsentry);
00056
00057
00058 for(i=0; i < NUM_HANDLES; i++) {
00059
00060 easy_init(curl[i]);
00061
00062 snprintf(target_url, sizeof(target_url),
00063 "http://server.example.curl:%s/path/1512%04i",
00064 port, i + 1);
00065 target_url[sizeof(target_url) - 1] = '\0';
00066 easy_setopt(curl[i], CURLOPT_URL, target_url);
00067
00068 easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
00069
00070 easy_setopt(curl[i], CURLOPT_HEADER, 1L);
00071
00072 easy_setopt(curl[i], CURLOPT_DNS_USE_GLOBAL_CACHE, 1L);
00073 }
00074
00075
00076 easy_setopt(curl[0], CURLOPT_RESOLVE, slist);
00077
00078
00079 for(i=0; (i < NUM_HANDLES) && !res; i++)
00080 res = curl_easy_perform(curl[i]);
00081
00082 test_cleanup:
00083
00084 curl_easy_cleanup(curl[0]);
00085 curl_easy_cleanup(curl[1]);
00086 curl_slist_free_all(slist);
00087 curl_global_cleanup();
00088
00089 return res;
00090 }
00091