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 "testutil.h"
00025 #include "warnless.h"
00026 #include "memdebug.h"
00027
00028 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream);
00029 size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream);
00030
00031 unsigned long realHeaderSize = 0;
00032
00033 int test(char *URL)
00034 {
00035 long headerSize;
00036 CURLcode code;
00037 CURL *curl = NULL;
00038 int res = 0;
00039
00040 global_init(CURL_GLOBAL_ALL);
00041
00042 easy_init(curl);
00043
00044 easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
00045
00046 easy_setopt(curl, CURLOPT_WRITEFUNCTION, *WriteOutput);
00047 easy_setopt(curl, CURLOPT_HEADERFUNCTION, *WriteHeader);
00048
00049 easy_setopt(curl, CURLOPT_HEADER, 1L);
00050 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
00051 easy_setopt(curl, CURLOPT_URL, URL);
00052 easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
00053
00054 code = curl_easy_perform(curl);
00055 if(CURLE_OK != code) {
00056 fprintf(stderr, "%s:%d curl_easy_perform() failed, "
00057 "with code %d (%s)\n",
00058 __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
00059 res = TEST_ERR_MAJOR_BAD;
00060 goto test_cleanup;
00061 }
00062
00063 code = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
00064 if(CURLE_OK != code) {
00065 fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
00066 "with code %d (%s)\n",
00067 __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
00068 res = TEST_ERR_MAJOR_BAD;
00069 goto test_cleanup;
00070 }
00071
00072 printf("header length is ........: %lu\n", headerSize);
00073 printf("header length should be..: %lu\n", realHeaderSize);
00074
00075 test_cleanup:
00076
00077 curl_easy_cleanup(curl);
00078 curl_global_cleanup();
00079
00080 return res;
00081 }
00082
00083 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream)
00084 {
00085 fwrite(ptr, size, nmemb, stream);
00086 return nmemb * size;
00087 }
00088
00089 size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream)
00090 {
00091 (void)ptr;
00092 (void)stream;
00093
00094 realHeaderSize += curlx_uztoul(size * nmemb);
00095
00096 return nmemb * size;
00097 }