File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / tests / libtest / lib1594.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 3 10:01:16 2020 UTC (5 years ago) by misho
Branches: curl, MAIN
CVS tags: v7_70_0p4, HEAD
curl

    1: /***************************************************************************
    2:  *                                  _   _ ____  _
    3:  *  Project                     ___| | | |  _ \| |
    4:  *                             / __| | | | |_) | |
    5:  *                            | (__| |_| |  _ <| |___
    6:  *                             \___|\___/|_| \_\_____|
    7:  *
    8:  * Copyright (C) 1998 - 2019, 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: 
   23: /* Testing Retry-After header parser */
   24: 
   25: #include "test.h"
   26: 
   27: #include "memdebug.h"
   28: 
   29: int test(char *URL)
   30: {
   31:   struct curl_slist *header = NULL;
   32:   curl_off_t retry;
   33:   CURL *curl = NULL;
   34:   int res = 0;
   35: 
   36:   global_init(CURL_GLOBAL_ALL);
   37: 
   38:   easy_init(curl);
   39: 
   40:   easy_setopt(curl, CURLOPT_URL, URL);
   41: 
   42:   res = curl_easy_perform(curl);
   43:   if(res)
   44:     goto test_cleanup;
   45: 
   46:   res = curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry);
   47:   if(res)
   48:     goto test_cleanup;
   49: 
   50: #ifdef LIB1596
   51:   /* we get a relative number of seconds, so add the number of seconds
   52:      we're at to make it a somewhat stable number. Then remove accuracy. */
   53:   retry += time(NULL);
   54:   retry /= 10000;
   55: #endif
   56:   printf("Retry-After: %" CURL_FORMAT_CURL_OFF_T "\n", retry);
   57: 
   58: test_cleanup:
   59: 
   60:   /* always cleanup */
   61:   curl_easy_cleanup(curl);
   62:   curl_slist_free_all(header);
   63:   curl_global_cleanup();
   64: 
   65:   return res;
   66: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>