lib1511.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, 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.haxx.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. ***************************************************************************/
  22. #include "test.h"
  23. #include "memdebug.h"
  24. int test(char *URL)
  25. {
  26. long unmet;
  27. CURL *curl = NULL;
  28. int res = 0;
  29. global_init(CURL_GLOBAL_ALL);
  30. easy_init(curl);
  31. easy_setopt(curl, CURLOPT_URL, URL);
  32. easy_setopt(curl, CURLOPT_HEADER, 1L);
  33. easy_setopt(curl, CURLOPT_TIMECONDITION, (long)CURL_TIMECOND_IFMODSINCE);
  34. /* TIMEVALUE in the future */
  35. easy_setopt(curl, CURLOPT_TIMEVALUE, 1566210680L);
  36. res = curl_easy_perform(curl);
  37. if(res)
  38. goto test_cleanup;
  39. curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
  40. if(unmet != 1L) {
  41. res = TEST_ERR_FAILURE; /* not correct */
  42. goto test_cleanup;
  43. }
  44. /* TIMEVALUE in the past */
  45. easy_setopt(curl, CURLOPT_TIMEVALUE, 1L);
  46. res = curl_easy_perform(curl);
  47. if(res)
  48. goto test_cleanup;
  49. curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
  50. if(unmet != 0L) {
  51. res = TEST_ERR_FAILURE; /* not correct */
  52. goto test_cleanup;
  53. }
  54. res = TEST_ERR_SUCCESS; /* this is where we should be */
  55. test_cleanup:
  56. /* always cleanup */
  57. curl_easy_cleanup(curl);
  58. curl_global_cleanup();
  59. return res;
  60. }