1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, 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 https://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 ***************************************************************************/
26 static int progress_callback(void *clientp, double dltotal,
27 double dlnow, double ultotal, double ulnow)
33 if((dltotal > 0.0) && (dlnow > dltotal)) {
34 /* this should not happen with test case 599 */
35 printf("%.0f > %.0f !!\n", dltotal, dlnow);
45 CURLcode res=CURLE_OK;
46 double content_length = 0.0;
48 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
49 fprintf(stderr, "curl_global_init() failed\n");
50 return TEST_ERR_MAJOR_BAD;
53 curl = curl_easy_init();
55 fprintf(stderr, "curl_easy_init() failed\n");
56 curl_global_cleanup();
57 return TEST_ERR_MAJOR_BAD;
60 /* First set the URL that is about to receive our POST. */
61 test_setopt(curl, CURLOPT_URL, URL);
63 /* we want to use our own progress function */
64 test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
65 test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
67 /* get verbose debug output please */
68 test_setopt(curl, CURLOPT_VERBOSE, 1L);
70 /* follow redirects */
71 test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
73 /* include headers in the output */
74 test_setopt(curl, CURLOPT_HEADER, 1L);
76 /* Perform the request, res will get the return code */
77 res = curl_easy_perform(curl);
81 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
83 moo = fopen(libtest_arg2, "wb");
85 fprintf(moo, "CL: %.0f\n", content_length);
93 curl_easy_cleanup(curl);
94 curl_global_cleanup();