1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
25 * Simply download a HTTPS file!
27 * This test was added after the HTTPS-using-multi-interface with OpenSSL
28 * regression of 7.19.1 to hopefully prevent this embarassing mistake from
29 * appearing again... Unfortunately the bug wasn't triggered by this test,
30 * which presumably is because the connect to a local server is too
31 * fast/different compared to the real/distant servers we saw the bug happen
37 CURLM *multi_handle = NULL;
41 int still_running; /* keep number of running handles */
43 http_handle = curl_easy_init();
45 return TEST_ERR_MAJOR_BAD;
48 test_setopt(http_handle, CURLOPT_URL, URL);
49 test_setopt(http_handle, CURLOPT_HEADER, 1L);
50 test_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
51 test_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
53 /* init a multi stack */
54 multi_handle = curl_multi_init();
56 curl_easy_cleanup(http_handle);
57 return TEST_ERR_MAJOR_BAD;
60 /* add the individual transfers */
61 curl_multi_add_handle(multi_handle, http_handle);
63 /* we start some action by calling perform right away */
65 code = curl_multi_perform(multi_handle, &still_running);
66 } while(code == CURLM_CALL_MULTI_PERFORM);
68 while(still_running) {
69 struct timeval timeout;
70 int rc; /* select() return code */
81 /* set a suitable timeout to play around with */
85 /* get file descriptors from the transfers */
86 curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
88 /* In a real-world program you OF COURSE check the return code of the
89 function calls, *and* you make sure that maxfd is bigger than -1 so
90 that the call to select() below makes sense! */
92 rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
100 /* timeout or readable/writable sockets */
102 code = curl_multi_perform(multi_handle, &still_running);
103 } while(code == CURLM_CALL_MULTI_PERFORM);
111 curl_multi_cleanup(multi_handle);
113 curl_easy_cleanup(http_handle);
114 curl_global_cleanup();