quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

lib503.c (2588B)


      1 /***************************************************************************
      2  *                                  _   _ ____  _
      3  *  Project                     ___| | | |  _ \| |
      4  *                             / __| | | | |_) | |
      5  *                            | (__| |_| |  _ <| |___
      6  *                             \___|\___/|_| \_\_____|
      7  *
      8  * Copyright (C) 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.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 #include "first.h"
     25 
     26 #include "memdebug.h"
     27 
     28 /*
     29  * Source code in here hugely as reported in bug report 651460 by
     30  * Christopher R. Palmer.
     31  *
     32  * Use multi interface to get HTTPS document over proxy, and provide
     33  * auth info.
     34  */
     35 
     36 static CURLcode test_lib503(char *URL)
     37 {
     38   CURL *c = NULL;
     39   CURLM *m = NULL;
     40   CURLcode res = CURLE_OK;
     41   int running;
     42 
     43   start_test_timing();
     44 
     45   global_init(CURL_GLOBAL_ALL);
     46 
     47   easy_init(c);
     48 
     49   easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
     50   easy_setopt(c, CURLOPT_URL, URL);
     51   easy_setopt(c, CURLOPT_USERPWD, "test:ing");
     52   easy_setopt(c, CURLOPT_PROXYUSERNAME, "test%20");
     53   easy_setopt(c, CURLOPT_PROXYPASSWORD, "ing%41");
     54   easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
     55   easy_setopt(c, CURLOPT_HEADER, 1L);
     56   easy_setopt(c, CURLOPT_VERBOSE, 1L);
     57 
     58   multi_init(m);
     59 
     60   multi_add_handle(m, c);
     61 
     62   for(;;) {
     63     struct timeval interval;
     64     fd_set rd, wr, exc;
     65     int maxfd = -99;
     66 
     67     interval.tv_sec = 1;
     68     interval.tv_usec = 0;
     69 
     70     multi_perform(m, &running);
     71 
     72     abort_on_test_timeout();
     73 
     74     if(!running)
     75       break; /* done */
     76 
     77     FD_ZERO(&rd);
     78     FD_ZERO(&wr);
     79     FD_ZERO(&exc);
     80 
     81     multi_fdset(m, &rd, &wr, &exc, &maxfd);
     82 
     83     /* At this point, maxfd is guaranteed to be greater or equal than -1. */
     84 
     85     select_test(maxfd + 1, &rd, &wr, &exc, &interval);
     86 
     87     abort_on_test_timeout();
     88   }
     89 
     90 test_cleanup:
     91 
     92   /* proper cleanup sequence - type PA */
     93 
     94   curl_multi_remove_handle(m, c);
     95   curl_multi_cleanup(m);
     96   curl_easy_cleanup(c);
     97   curl_global_cleanup();
     98 
     99   return res;
    100 }