1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2018, 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 supposed to be identical to 547 except that this uses the
24 * multi interface and 547 is easy interface.
28 * argv3 = proxyuser:password
36 #define TEST_HANG_TIMEOUT 60 * 1000
38 static const char uploadthis[] =
39 #ifdef CURL_DOES_CONVERSIONS
40 /* ASCII representation with escape sequences for non-ASCII platforms */
41 "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62\x6c\x75\x72"
42 "\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20\x74\x6f\x20\x75\x70\x6c"
45 "this is the blurb we want to upload\n";
48 static size_t readcallback(void *ptr,
53 int *counter = (int *)clientp;
56 /* only do this once and then require a clearing of this */
57 fprintf(stderr, "READ ALREADY DONE!\n");
60 (*counter)++; /* bump */
62 if(size * nmemb > strlen(uploadthis)) {
63 fprintf(stderr, "READ!\n");
64 strcpy(ptr, uploadthis);
65 return strlen(uploadthis);
67 fprintf(stderr, "READ NOT FINE!\n");
70 static curlioerr ioctlcallback(CURL *handle,
74 int *counter = (int *)clientp;
75 (void)handle; /* unused */
76 if(cmd == CURLIOCMD_RESTARTREAD) {
77 fprintf(stderr, "REWIND!\n");
78 *counter = 0; /* clear counter to make the read callback restart */
94 global_init(CURL_GLOBAL_ALL);
98 easy_setopt(curl, CURLOPT_URL, URL);
99 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
100 easy_setopt(curl, CURLOPT_HEADER, 1L);
102 /* read the POST data from a callback */
103 easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
104 easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
105 easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
106 easy_setopt(curl, CURLOPT_READDATA, &counter);
107 /* We CANNOT do the POST fine without setting the size (or choose
109 easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(uploadthis));
111 easy_setopt(curl, CURLOPT_POST, 1L);
112 easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
113 easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
114 easy_setopt(curl, CURLOPT_PROXYAUTH,
115 (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
119 multi_add_handle(m, curl);
122 struct timeval timeout;
123 fd_set fdread, fdwrite, fdexcep;
127 timeout.tv_usec = 100000L; /* 100 ms */
129 multi_perform(m, &running);
131 abort_on_test_timeout();
134 sleep(1); /* avoid ctl-10 dump */
144 multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
146 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
148 select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
150 abort_on_test_timeout();
155 /* proper cleanup sequence - type PA */
157 curl_multi_remove_handle(m, curl);
158 curl_multi_cleanup(m);
159 curl_easy_cleanup(curl);
160 curl_global_cleanup();