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