1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
13 * Simply download a HTTPS file!
15 * This test was added after the HTTPS-using-multi-interface with OpenSSL
16 * regression of 7.19.1 to hopefully prevent this embarassing mistake from
17 * appearing again... Unfortunately the bug wasn't triggered by this test,
18 * which presumably is because the connect to a local server is too
19 * fast/different compared to the real/distant servers we saw the bug happen
25 CURLM *multi_handle = NULL;
29 int still_running; /* keep number of running handles */
31 http_handle = curl_easy_init();
33 return TEST_ERR_MAJOR_BAD;
36 test_setopt(http_handle, CURLOPT_URL, URL);
37 test_setopt(http_handle, CURLOPT_HEADER, 1L);
38 test_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
39 test_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
41 /* init a multi stack */
42 multi_handle = curl_multi_init();
44 curl_easy_cleanup(http_handle);
45 return TEST_ERR_MAJOR_BAD;
48 /* add the individual transfers */
49 curl_multi_add_handle(multi_handle, http_handle);
51 /* we start some action by calling perform right away */
53 code = curl_multi_perform(multi_handle, &still_running);
54 } while(code == CURLM_CALL_MULTI_PERFORM);
56 while(still_running) {
57 struct timeval timeout;
58 int rc; /* select() return code */
69 /* set a suitable timeout to play around with */
73 /* get file descriptors from the transfers */
74 curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
76 /* In a real-world program you OF COURSE check the return code of the
77 function calls, *and* you make sure that maxfd is bigger than -1 so
78 that the call to select() below makes sense! */
80 rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
88 /* timeout or readable/writable sockets */
90 code = curl_multi_perform(multi_handle, &still_running);
91 } while(code == CURLM_CALL_MULTI_PERFORM);
99 curl_multi_cleanup(multi_handle);
101 curl_easy_cleanup(http_handle);
102 curl_global_cleanup();