lib1509.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
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); /* set in first.c */
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 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05