Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/curl/tests/libtest/lib1542.c
2649 views
1
/***************************************************************************
2
* _ _ ____ _
3
* Project ___| | | | _ \| |
4
* / __| | | | |_) | |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
7
*
8
* Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9
*
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.se/docs/copyright.html.
13
*
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.
17
*
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
* KIND, either express or implied.
20
*
21
* SPDX-License-Identifier: curl
22
*
23
***************************************************************************/
24
25
/*
26
* Test CURLOPT_MAXLIFETIME_CONN:
27
* Send four requests, sleeping between the second and third and setting
28
* MAXLIFETIME_CONN between the third and fourth. The first three requests
29
* should use the same connection, and the fourth request should close the
30
* first connection and open a second.
31
*/
32
33
#include "first.h"
34
35
#include "testtrace.h"
36
#include "memdebug.h"
37
38
static CURLcode test_lib1542(const char *URL)
39
{
40
CURL *curl = NULL;
41
CURLcode res = CURLE_OK;
42
43
global_init(CURL_GLOBAL_ALL);
44
45
res_easy_init(curl);
46
47
easy_setopt(curl, CURLOPT_URL, URL);
48
49
debug_config.nohex = TRUE;
50
debug_config.tracetime = FALSE;
51
easy_setopt(curl, CURLOPT_DEBUGDATA, &debug_config);
52
easy_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
53
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
54
55
res = curl_easy_perform(curl);
56
if(res)
57
goto test_cleanup;
58
59
res = curl_easy_perform(curl);
60
if(res)
61
goto test_cleanup;
62
63
/* CURLOPT_MAXLIFETIME_CONN is inclusive - the connection needs to be 2
64
* seconds old */
65
curlx_wait_ms(2000);
66
67
res = curl_easy_perform(curl);
68
if(res)
69
goto test_cleanup;
70
71
easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 1L);
72
73
res = curl_easy_perform(curl);
74
if(res)
75
goto test_cleanup;
76
77
test_cleanup:
78
79
curl_easy_cleanup(curl);
80
curl_global_cleanup();
81
82
return res;
83
}
84
85