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 ***************************************************************************/
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 #define UPLOADTHIS "this is the blurb we want to upload\n"
40 static size_t readcallback(void *ptr,
45 int *counter = (int *)clientp;
48 /* only do this once and then require a clearing of this */
49 fprintf(stderr, "READ ALREADY DONE!\n");
52 (*counter)++; /* bump */
54 if(size * nmemb > strlen(UPLOADTHIS)) {
55 fprintf(stderr, "READ!\n");
56 strcpy(ptr, UPLOADTHIS);
57 return strlen(UPLOADTHIS);
59 fprintf(stderr, "READ NOT FINE!\n");
62 static curlioerr ioctlcallback(CURL *handle,
66 int *counter = (int *)clientp;
67 (void)handle; /* unused */
68 if(cmd == CURLIOCMD_RESTARTREAD) {
69 fprintf(stderr, "REWIND!\n");
70 *counter = 0; /* clear counter to make the read callback restart */
86 global_init(CURL_GLOBAL_ALL);
90 easy_setopt(curl, CURLOPT_URL, URL);
91 easy_setopt(curl, CURLOPT_VERBOSE, 1L);
92 easy_setopt(curl, CURLOPT_HEADER, 1L);
94 /* read the POST data from a callback */
95 easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
96 easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
97 easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
98 easy_setopt(curl, CURLOPT_READDATA, &counter);
99 /* We CANNOT do the POST fine without setting the size (or choose chunked)! */
100 easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
102 easy_setopt(curl, CURLOPT_POST, 1L);
103 #ifdef CURL_DOES_CONVERSIONS
104 /* Convert the POST data to ASCII. */
105 easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
107 easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
108 easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
109 easy_setopt(curl, CURLOPT_PROXYAUTH,
110 (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
114 multi_add_handle(m, curl);
117 struct timeval timeout;
118 fd_set fdread, fdwrite, fdexcep;
122 timeout.tv_usec = 100000L; /* 100 ms */
124 multi_perform(m, &running);
126 abort_on_test_timeout();
129 sleep(1); /* avoid ctl-10 dump */
139 multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
141 /* At this point, maxfd is guaranteed to be greater or equal than -1. */
143 select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
145 abort_on_test_timeout();
150 /* proper cleanup sequence - type PA */
152 curl_multi_remove_handle(m, curl);
153 curl_multi_cleanup(m);
154 curl_easy_cleanup(curl);
155 curl_global_cleanup();