~ubuntu-branches/ubuntu/vivid/libmicrohttpd/vivid

« back to all changes in this revision

Viewing changes to src/testcurl/daemontest_postform.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-05-18 12:41:53 UTC
  • mfrom: (1.3.1 upstream) (7.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090518124153-nfup3gwcwpt4soes
Tags: 0.4.2-1
MergingĀ upstreamĀ versionĀ 0.4.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
  return 0;
252
252
}
253
253
 
 
254
static int
 
255
testMultithreadedPoolPost ()
 
256
{
 
257
  struct MHD_Daemon *d;
 
258
  CURL *c;
 
259
  char buf[2048];
 
260
  struct CBC cbc;
 
261
  CURLcode errornum;
 
262
  struct curl_httppost *pd;
 
263
 
 
264
  cbc.buf = buf;
 
265
  cbc.size = 2048;
 
266
  cbc.pos = 0;
 
267
  d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
 
268
                        1081, NULL, NULL, &ahc_echo, NULL,
 
269
                        MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END);
 
270
  if (d == NULL)
 
271
    return 16;
 
272
  c = curl_easy_init ();
 
273
  curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world");
 
274
  curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
 
275
  curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
 
276
  pd = make_form ();
 
277
  curl_easy_setopt (c, CURLOPT_HTTPPOST, pd);
 
278
  curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
 
279
  curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
 
280
  if (oneone)
 
281
    curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
 
282
  else
 
283
    curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
 
284
  curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 5L);
 
285
  // NOTE: use of CONNECTTIMEOUT without also
 
286
  //   setting NOSIGNAL results in really weird
 
287
  //   crashes on my system!
 
288
  curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
 
289
  if (CURLE_OK != (errornum = curl_easy_perform (c)))
 
290
    {
 
291
      fprintf (stderr,
 
292
               "curl_easy_perform failed: `%s'\n",
 
293
               curl_easy_strerror (errornum));
 
294
      curl_easy_cleanup (c);
 
295
      curl_formfree (pd);
 
296
      MHD_stop_daemon (d);
 
297
      return 32;
 
298
    }
 
299
  curl_easy_cleanup (c);
 
300
  curl_formfree (pd);
 
301
  MHD_stop_daemon (d);
 
302
  if (cbc.pos != strlen ("/hello_world"))
 
303
    return 64;
 
304
  if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
 
305
    return 128;
 
306
  return 0;
 
307
}
254
308
 
255
309
static int
256
310
testExternalPost ()
394
448
    return 2;
395
449
  errorCount += testInternalPost ();
396
450
  errorCount += testMultithreadedPost ();
 
451
  errorCount += testMultithreadedPoolPost ();
397
452
  errorCount += testExternalPost ();
398
453
  if (errorCount != 0)
399
454
    fprintf (stderr, "Error (code: %u)\n", errorCount);