/***************************************************************************1* _ _ ____ _2* Project ___| | | | _ \| |3* / __| | | | |_) | |4* | (__| |_| | _ <| |___5* \___|\___/|_| \_\_____|6*7* Copyright (C) Daniel Stenberg, <[email protected]>, et al.8*9* This software is licensed as described in the file COPYING, which10* you should have received as part of this distribution. The terms11* are also available at https://curl.se/docs/copyright.html.12*13* You may opt to use, copy, modify, merge, publish, distribute and/or sell14* copies of the Software, and permit persons to whom the Software is15* furnished to do so, under the terms of the COPYING file.16*17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY18* KIND, either express or implied.19*20* SPDX-License-Identifier: curl21*22***************************************************************************/23#include "first.h"2425/* test case and code based on https://github.com/curl/curl/issues/3927 */2627#include "memdebug.h"2829static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c,30curl_off_t d, curl_off_t e)31{32(void)a;33(void)b;34(void)c;35(void)d;36(void)e;37return 0;38}3940static size_t t1523_write_cb(char *d, size_t n, size_t l, void *p)41{42/* take care of the data here, ignored in this example */43(void)d;44(void)p;45return n*l;46}4748static CURLcode run(CURL *curl, long limit, long time)49{50curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, limit);51curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, time);52return curl_easy_perform(curl);53}5455static CURLcode test_lib1523(const char *URL)56{57CURLcode ret;58CURL *curl;59char buffer[CURL_ERROR_SIZE];60curl_global_init(CURL_GLOBAL_ALL);61curl = curl_easy_init();62curl_easy_setopt(curl, CURLOPT_URL, URL);63curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, t1523_write_cb);64curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer);65curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);66curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);6768ret = run(curl, 1, 2);69if(ret)70curl_mfprintf(stderr, "error (%d) %s\n", ret, buffer);7172ret = run(curl, 12000, 1);73if(ret != CURLE_OPERATION_TIMEDOUT)74curl_mfprintf(stderr, "error (%d) %s\n", ret, buffer);75else76ret = CURLE_OK;7778curl_easy_cleanup(curl);79curl_global_cleanup();8081return ret;82}838485