lib599.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, 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 "memdebug.h"
00025 
00026 static int progress_callback(void *clientp, double dltotal,
00027                              double dlnow, double ultotal, double ulnow)
00028 {
00029   (void)clientp;
00030   (void)ulnow;
00031   (void)ultotal;
00032 
00033   if((dltotal > 0.0) && (dlnow > dltotal)) {
00034     /* this should not happen with test case 599 */
00035     printf("%.0f > %.0f !!\n", dltotal, dlnow);
00036     return -1;
00037   }
00038 
00039   return 0;
00040 }
00041 
00042 int test(char *URL)
00043 {
00044   CURL *curl;
00045   CURLcode res=CURLE_OK;
00046   double content_length = 0.0;
00047 
00048   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00049     fprintf(stderr, "curl_global_init() failed\n");
00050     return TEST_ERR_MAJOR_BAD;
00051   }
00052 
00053   curl = curl_easy_init();
00054   if(!curl) {
00055     fprintf(stderr, "curl_easy_init() failed\n");
00056     curl_global_cleanup();
00057     return TEST_ERR_MAJOR_BAD;
00058   }
00059 
00060   /* First set the URL that is about to receive our POST. */
00061   test_setopt(curl, CURLOPT_URL, URL);
00062 
00063   /* we want to use our own progress function */
00064   test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
00065   test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
00066 
00067   /* get verbose debug output please */
00068   test_setopt(curl, CURLOPT_VERBOSE, 1L);
00069 
00070   /* follow redirects */
00071   test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
00072 
00073   /* include headers in the output */
00074   test_setopt(curl, CURLOPT_HEADER, 1L);
00075 
00076   /* Perform the request, res will get the return code */
00077   res = curl_easy_perform(curl);
00078 
00079   if(!res) {
00080     FILE *moo;
00081     res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
00082                             &content_length);
00083     moo = fopen(libtest_arg2, "wb");
00084     if(moo) {
00085       fprintf(moo, "CL: %.0f\n", content_length);
00086       fclose(moo);
00087     }
00088   }
00089 
00090 test_cleanup:
00091 
00092   /* always cleanup */
00093   curl_easy_cleanup(curl);
00094   curl_global_cleanup();
00095 
00096   return res;
00097 }


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