aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemontest_postform.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemontest_postform.c')
-rw-r--r--src/daemon/daemontest_postform.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/daemon/daemontest_postform.c b/src/daemon/daemontest_postform.c
index 0da5a74d..d02e8111 100644
--- a/src/daemon/daemontest_postform.c
+++ b/src/daemon/daemontest_postform.c
@@ -106,7 +106,7 @@ ahc_echo (void *cls,
106 eok = 0; 106 eok = 0;
107 pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok); 107 pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok);
108 if (pp == NULL) 108 if (pp == NULL)
109 abort(); 109 abort ();
110 *unused = pp; 110 *unused = pp;
111 } 111 }
112 MHD_post_process (pp, upload_data, *upload_data_size); 112 MHD_post_process (pp, upload_data, *upload_data_size);
@@ -125,15 +125,16 @@ ahc_echo (void *cls,
125 return MHD_YES; 125 return MHD_YES;
126} 126}
127 127
128static struct curl_httppost * 128static struct curl_httppost *
129make_form() { 129make_form ()
130 struct curl_httppost* post = NULL; 130{
131 struct curl_httppost* last = NULL; 131 struct curl_httppost *post = NULL;
132 132 struct curl_httppost *last = NULL;
133 curl_formadd(&post, &last, CURLFORM_COPYNAME, "name", 133
134 CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); 134 curl_formadd (&post, &last, CURLFORM_COPYNAME, "name",
135 curl_formadd(&post, &last, CURLFORM_COPYNAME, "project", 135 CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END);
136 CURLFORM_COPYCONTENTS, "curl", CURLFORM_END); 136 curl_formadd (&post, &last, CURLFORM_COPYNAME, "project",
137 CURLFORM_COPYCONTENTS, "curl", CURLFORM_END);
137 return post; 138 return post;
138} 139}
139 140
@@ -146,7 +147,7 @@ testInternalPost ()
146 char buf[2048]; 147 char buf[2048];
147 struct CBC cbc; 148 struct CBC cbc;
148 CURLcode errornum; 149 CURLcode errornum;
149 struct curl_httppost * pd; 150 struct curl_httppost *pd;
150 151
151 cbc.buf = buf; 152 cbc.buf = buf;
152 cbc.size = 2048; 153 cbc.size = 2048;
@@ -159,8 +160,8 @@ testInternalPost ()
159 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); 160 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world");
160 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 161 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
161 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 162 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
162 pd = make_form(); 163 pd = make_form ();
163 curl_easy_setopt(c, CURLOPT_HTTPPOST, pd); 164 curl_easy_setopt (c, CURLOPT_HTTPPOST, pd);
164 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 165 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
165 curl_easy_setopt (c, CURLOPT_TIMEOUT, 2L); 166 curl_easy_setopt (c, CURLOPT_TIMEOUT, 2L);
166 if (oneone) 167 if (oneone)
@@ -178,12 +179,12 @@ testInternalPost ()
178 "curl_easy_perform failed: `%s'\n", 179 "curl_easy_perform failed: `%s'\n",
179 curl_easy_strerror (errornum)); 180 curl_easy_strerror (errornum));
180 curl_easy_cleanup (c); 181 curl_easy_cleanup (c);
181 curl_formfree(pd); 182 curl_formfree (pd);
182 MHD_stop_daemon (d); 183 MHD_stop_daemon (d);
183 return 2; 184 return 2;
184 } 185 }
185 curl_easy_cleanup (c); 186 curl_easy_cleanup (c);
186 curl_formfree(pd); 187 curl_formfree (pd);
187 MHD_stop_daemon (d); 188 MHD_stop_daemon (d);
188 if (cbc.pos != strlen ("/hello_world")) 189 if (cbc.pos != strlen ("/hello_world"))
189 return 4; 190 return 4;
@@ -200,7 +201,7 @@ testMultithreadedPost ()
200 char buf[2048]; 201 char buf[2048];
201 struct CBC cbc; 202 struct CBC cbc;
202 CURLcode errornum; 203 CURLcode errornum;
203 struct curl_httppost * pd; 204 struct curl_httppost *pd;
204 205
205 cbc.buf = buf; 206 cbc.buf = buf;
206 cbc.size = 2048; 207 cbc.size = 2048;
@@ -213,8 +214,8 @@ testMultithreadedPost ()
213 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 214 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world");
214 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 215 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
215 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 216 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
216 pd = make_form(); 217 pd = make_form ();
217 curl_easy_setopt(c, CURLOPT_HTTPPOST, pd); 218 curl_easy_setopt (c, CURLOPT_HTTPPOST, pd);
218 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 219 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
219 curl_easy_setopt (c, CURLOPT_TIMEOUT, 2L); 220 curl_easy_setopt (c, CURLOPT_TIMEOUT, 2L);
220 if (oneone) 221 if (oneone)
@@ -232,12 +233,12 @@ testMultithreadedPost ()
232 "curl_easy_perform failed: `%s'\n", 233 "curl_easy_perform failed: `%s'\n",
233 curl_easy_strerror (errornum)); 234 curl_easy_strerror (errornum));
234 curl_easy_cleanup (c); 235 curl_easy_cleanup (c);
235 curl_formfree(pd); 236 curl_formfree (pd);
236 MHD_stop_daemon (d); 237 MHD_stop_daemon (d);
237 return 32; 238 return 32;
238 } 239 }
239 curl_easy_cleanup (c); 240 curl_easy_cleanup (c);
240 curl_formfree(pd); 241 curl_formfree (pd);
241 MHD_stop_daemon (d); 242 MHD_stop_daemon (d);
242 if (cbc.pos != strlen ("/hello_world")) 243 if (cbc.pos != strlen ("/hello_world"))
243 return 64; 244 return 64;
@@ -264,7 +265,7 @@ testExternalPost ()
264 struct CURLMsg *msg; 265 struct CURLMsg *msg;
265 time_t start; 266 time_t start;
266 struct timeval tv; 267 struct timeval tv;
267 struct curl_httppost * pd; 268 struct curl_httppost *pd;
268 269
269 multi = NULL; 270 multi = NULL;
270 cbc.buf = buf; 271 cbc.buf = buf;
@@ -278,8 +279,8 @@ testExternalPost ()
278 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world"); 279 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world");
279 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 280 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
280 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 281 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
281 pd = make_form(); 282 pd = make_form ();
282 curl_easy_setopt(c, CURLOPT_HTTPPOST, pd); 283 curl_easy_setopt (c, CURLOPT_HTTPPOST, pd);
283 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 284 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
284 curl_easy_setopt (c, CURLOPT_TIMEOUT, 5L); 285 curl_easy_setopt (c, CURLOPT_TIMEOUT, 5L);
285 if (oneone) 286 if (oneone)
@@ -297,7 +298,7 @@ testExternalPost ()
297 if (multi == NULL) 298 if (multi == NULL)
298 { 299 {
299 curl_easy_cleanup (c); 300 curl_easy_cleanup (c);
300 curl_formfree(pd); 301 curl_formfree (pd);
301 MHD_stop_daemon (d); 302 MHD_stop_daemon (d);
302 return 512; 303 return 512;
303 } 304 }
@@ -305,7 +306,7 @@ testExternalPost ()
305 if (mret != CURLM_OK) 306 if (mret != CURLM_OK)
306 { 307 {
307 curl_multi_cleanup (multi); 308 curl_multi_cleanup (multi);
308 curl_formfree(pd); 309 curl_formfree (pd);
309 curl_easy_cleanup (c); 310 curl_easy_cleanup (c);
310 MHD_stop_daemon (d); 311 MHD_stop_daemon (d);
311 return 1024; 312 return 1024;
@@ -325,7 +326,7 @@ testExternalPost ()
325 curl_multi_cleanup (multi); 326 curl_multi_cleanup (multi);
326 curl_easy_cleanup (c); 327 curl_easy_cleanup (c);
327 MHD_stop_daemon (d); 328 MHD_stop_daemon (d);
328 curl_formfree(pd); 329 curl_formfree (pd);
329 return 2048; 330 return 2048;
330 } 331 }
331 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) 332 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
@@ -333,7 +334,7 @@ testExternalPost ()
333 curl_multi_remove_handle (multi, c); 334 curl_multi_remove_handle (multi, c);
334 curl_multi_cleanup (multi); 335 curl_multi_cleanup (multi);
335 curl_easy_cleanup (c); 336 curl_easy_cleanup (c);
336 curl_formfree(pd); 337 curl_formfree (pd);
337 MHD_stop_daemon (d); 338 MHD_stop_daemon (d);
338 return 4096; 339 return 4096;
339 } 340 }
@@ -368,7 +369,7 @@ testExternalPost ()
368 curl_easy_cleanup (c); 369 curl_easy_cleanup (c);
369 curl_multi_cleanup (multi); 370 curl_multi_cleanup (multi);
370 } 371 }
371 curl_formfree(pd); 372 curl_formfree (pd);
372 MHD_stop_daemon (d); 373 MHD_stop_daemon (d);
373 if (cbc.pos != strlen ("/hello_world")) 374 if (cbc.pos != strlen ("/hello_world"))
374 return 8192; 375 return 8192;
@@ -388,10 +389,11 @@ main (int argc, char *const *argv)
388 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 389 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
389 return 2; 390 return 2;
390 errorCount += testInternalPost (); 391 errorCount += testInternalPost ();
391 if (0) { 392 if (0)
392 errorCount += testMultithreadedPost (); 393 {
393 errorCount += testExternalPost (); 394 errorCount += testMultithreadedPost ();
394 } 395 errorCount += testExternalPost ();
396 }
395 if (errorCount != 0) 397 if (errorCount != 0)
396 fprintf (stderr, "Error (code: %u)\n", errorCount); 398 fprintf (stderr, "Error (code: %u)\n", errorCount);
397 curl_global_cleanup (); 399 curl_global_cleanup ();