/***************************************************************************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 "test.h"33#include "testutil.h"34#include "testtrace.h"35#include "warnless.h"36#include "memdebug.h"3738CURLcode test(char *URL)39{40CURL *easy = NULL;41CURLcode res = CURLE_OK;4243global_init(CURL_GLOBAL_ALL);4445res_easy_init(easy);4647easy_setopt(easy, CURLOPT_URL, URL);4849libtest_debug_config.nohex = 1;50libtest_debug_config.tracetime = 0;51easy_setopt(easy, CURLOPT_DEBUGDATA, &libtest_debug_config);52easy_setopt(easy, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);53easy_setopt(easy, CURLOPT_VERBOSE, 1L);5455res = curl_easy_perform(easy);56if(res)57goto test_cleanup;5859res = curl_easy_perform(easy);60if(res)61goto test_cleanup;6263/* CURLOPT_MAXLIFETIME_CONN is inclusive - the connection needs to be 264* seconds old */65sleep(2);6667res = curl_easy_perform(easy);68if(res)69goto test_cleanup;7071easy_setopt(easy, CURLOPT_MAXLIFETIME_CONN, 1L);7273res = curl_easy_perform(easy);74if(res)75goto test_cleanup;7677test_cleanup:7879curl_easy_cleanup(easy);80curl_global_cleanup();8182return res;83}848586