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