/***************************************************************************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***************************************************************************/2324/*25* Test CURLOPT_MAXLIFETIME_CONN:26* Send four requests, sleeping between the second and third and setting27* MAXLIFETIME_CONN between the third and fourth. The first three requests28* should use the same connection, and the fourth request should close the29* first connection and open a second.30*/3132#include "first.h"3334#include "testtrace.h"35#include "memdebug.h"3637static CURLcode test_lib1542(const char *URL)38{39CURL *curl = NULL;40CURLcode res = CURLE_OK;4142global_init(CURL_GLOBAL_ALL);4344res_easy_init(curl);4546easy_setopt(curl, CURLOPT_URL, URL);4748debug_config.nohex = TRUE;49debug_config.tracetime = FALSE;50easy_setopt(curl, CURLOPT_DEBUGDATA, &debug_config);51easy_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);52easy_setopt(curl, CURLOPT_VERBOSE, 1L);5354res = curl_easy_perform(curl);55if(res)56goto test_cleanup;5758res = curl_easy_perform(curl);59if(res)60goto test_cleanup;6162/* CURLOPT_MAXLIFETIME_CONN is inclusive - the connection needs to be 263* seconds old */64curlx_wait_ms(2000);6566res = curl_easy_perform(curl);67if(res)68goto test_cleanup;6970easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 1L);7172res = curl_easy_perform(curl);73if(res)74goto test_cleanup;7576test_cleanup:7778curl_easy_cleanup(curl);79curl_global_cleanup();8081return res;82}838485