1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, 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 https://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 ***************************************************************************/
23 * This test case is based on the sample code provided by Saqib Ali
24 * https://curl.haxx.se/mail/lib-2011-03/0066.html
36 CURLM *multiHandle = NULL;
38 CURLMcode res = CURLM_OK;
40 global_init(CURL_GLOBAL_ALL);
42 multi_init(multiHandle);
46 easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
47 easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
48 easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
50 easy_setopt(curl, CURLOPT_UPLOAD, 1L);
51 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
53 easy_setopt(curl, CURLOPT_URL, URL);
54 easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
56 multi_add_handle(multiHandle, curl);
58 /* this tests if removing an easy handle immediately after multi
59 perform has been called succeeds or not. */
61 fprintf(stderr, "curl_multi_perform()...\n");
63 multi_perform(multiHandle, &stillRunning);
65 fprintf(stderr, "curl_multi_perform() succeeded\n");
67 fprintf(stderr, "curl_multi_remove_handle()...\n");
68 res = curl_multi_remove_handle(multiHandle, curl);
70 fprintf(stderr, "curl_multi_remove_handle() failed, "
71 "with code %d\n", (int)res);
73 fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
77 /* undocumented cleanup sequence - type UB */
79 curl_easy_cleanup(curl);
80 curl_multi_cleanup(multiHandle);
81 curl_global_cleanup();