1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
28 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream);
29 size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream);
31 unsigned long realHeaderSize = 0;
40 global_init(CURL_GLOBAL_ALL);
44 easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
46 easy_setopt(curl, CURLOPT_WRITEFUNCTION, *WriteOutput);
47 easy_setopt(curl, CURLOPT_HEADERFUNCTION, *WriteHeader);
49 easy_setopt(curl, CURLOPT_HEADER, 1L);
50 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
51 easy_setopt(curl, CURLOPT_URL, URL);
52 easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
54 code = curl_easy_perform(curl);
55 if(CURLE_OK != code) {
56 fprintf(stderr, "%s:%d curl_easy_perform() failed, "
57 "with code %d (%s)\n",
58 __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
59 res = TEST_ERR_MAJOR_BAD;
63 code = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
64 if(CURLE_OK != code) {
65 fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
66 "with code %d (%s)\n",
67 __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
68 res = TEST_ERR_MAJOR_BAD;
72 printf("header length is ........: %lu\n", headerSize);
73 printf("header length should be..: %lu\n", realHeaderSize);
77 curl_easy_cleanup(curl);
78 curl_global_cleanup();
83 size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream)
85 fwrite(ptr, size, nmemb, stream);
89 size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream)
94 realHeaderSize += curlx_uztoul(size * nmemb);