2013-04-23 02:07:15 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2023-01-02 20:51:48 +08:00
|
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2013-04-23 02:07:15 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2013-04-23 02:07:15 +08:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
*
|
2013-04-23 02:07:15 +08:00
|
|
|
***************************************************************************/
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include "memdebug.h"
|
|
|
|
|
2024-05-12 03:36:05 +08:00
|
|
|
CURLcode test(char *URL)
|
2013-04-23 02:07:15 +08:00
|
|
|
{
|
|
|
|
long unmet;
|
2016-11-23 14:53:24 +08:00
|
|
|
CURL *curl = NULL;
|
2024-05-12 03:36:05 +08:00
|
|
|
CURLcode res = CURLE_OK;
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
global_init(CURL_GLOBAL_ALL);
|
2013-07-11 23:01:02 +08:00
|
|
|
|
2013-04-23 02:07:15 +08:00
|
|
|
easy_init(curl);
|
|
|
|
|
|
|
|
easy_setopt(curl, CURLOPT_URL, URL);
|
|
|
|
easy_setopt(curl, CURLOPT_HEADER, 1L);
|
2013-07-11 23:01:02 +08:00
|
|
|
easy_setopt(curl, CURLOPT_TIMECONDITION, (long)CURL_TIMECOND_IFMODSINCE);
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
/* TIMEVALUE in the future */
|
2013-07-11 23:01:02 +08:00
|
|
|
easy_setopt(curl, CURLOPT_TIMEVALUE, 1566210680L);
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
res = curl_easy_perform(curl);
|
2013-07-11 23:01:02 +08:00
|
|
|
if(res)
|
2013-04-23 02:07:15 +08:00
|
|
|
goto test_cleanup;
|
|
|
|
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
|
2013-07-11 23:01:02 +08:00
|
|
|
if(unmet != 1L) {
|
|
|
|
res = TEST_ERR_FAILURE; /* not correct */
|
2013-04-23 02:07:15 +08:00
|
|
|
goto test_cleanup;
|
2013-07-11 23:01:02 +08:00
|
|
|
}
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
/* TIMEVALUE in the past */
|
2013-07-11 23:01:02 +08:00
|
|
|
easy_setopt(curl, CURLOPT_TIMEVALUE, 1L);
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
res = curl_easy_perform(curl);
|
2013-07-11 23:01:02 +08:00
|
|
|
if(res)
|
2013-04-23 02:07:15 +08:00
|
|
|
goto test_cleanup;
|
|
|
|
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
|
2021-04-19 16:46:11 +08:00
|
|
|
if(unmet) {
|
2013-07-11 23:01:02 +08:00
|
|
|
res = TEST_ERR_FAILURE; /* not correct */
|
2013-04-23 02:07:15 +08:00
|
|
|
goto test_cleanup;
|
2013-07-11 23:01:02 +08:00
|
|
|
}
|
2013-04-23 02:07:15 +08:00
|
|
|
|
2013-07-11 23:01:02 +08:00
|
|
|
res = TEST_ERR_SUCCESS; /* this is where we should be */
|
2013-04-23 02:07:15 +08:00
|
|
|
|
|
|
|
test_cleanup:
|
|
|
|
|
2013-07-11 23:01:02 +08:00
|
|
|
/* always cleanup */
|
2013-04-23 02:07:15 +08:00
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
curl_global_cleanup();
|
|
|
|
|
2013-07-11 23:01:02 +08:00
|
|
|
return res;
|
2013-04-23 02:07:15 +08:00
|
|
|
}
|