bool write_output;
};
+static struct ioloop *ioloop;
+
static void payload_input(struct http_test_request *req)
{
const unsigned char *data;
got_request_response(const struct http_response *response,
struct http_test_request *req)
{
+ io_loop_stop(ioloop);
+
if (response->status / 100 != 2) {
i_error("HTTP Request failed: %s", response->reason);
i_free(req);
struct dns_client *dns_client;
struct dns_lookup_settings dns_set;
struct http_client_settings http_set;
- struct http_client *http_client;
+ struct http_client_context *http_cctx;
+ struct http_client *http_client1, *http_client2, *http_client3, *http_client4;
struct ssl_iostream_settings ssl_set;
const char *error;
- struct ioloop *ioloop;
lib_init();
#ifdef HAVE_OPENSSL
http_set.debug = TRUE;
http_set.rawlog_dir = "/tmp/http-test";
- http_client = http_client_init(&http_set);
+ http_cctx = http_client_context_create(&http_set);
+
+ http_client1 = http_client_init_shared(http_cctx, NULL);
+ http_client2 = http_client_init_shared(http_cctx, NULL);
+ http_client3 = http_client_init_shared(http_cctx, NULL);
+ http_client4 = http_client_init_shared(http_cctx, NULL);
switch (argc) {
case 1:
- run_tests(http_client);
+ run_tests(http_client1);
+ run_tests(http_client2);
+ run_tests(http_client3);
+ run_tests(http_client4);
break;
case 2:
- run_http_get(http_client, argv[1]);
+ run_http_get(http_client1, argv[1]);
+ run_http_get(http_client2, argv[1]);
+ run_http_get(http_client3, argv[1]);
+ run_http_get(http_client4, argv[1]);
break;
case 3:
- run_http_post(http_client, argv[1], argv[2]);
+ run_http_post(http_client1, argv[1], argv[2]);
+ run_http_post(http_client2, argv[1], argv[2]);
+ run_http_post(http_client3, argv[1], argv[2]);
+ run_http_post(http_client4, argv[1], argv[2]);
break;
default:
i_fatal("Too many parameters");
}
- http_client_wait(http_client);
- http_client_deinit(&http_client);
+ for (;;) {
+ bool pending = FALSE;
+
+ if (http_client_get_pending_request_count(http_client1) > 0) {
+ i_debug("Requests still pending in client 1");
+ pending = TRUE;
+ } else if (http_client_get_pending_request_count(http_client2) > 0) {
+ i_debug("Requests still pending in client 2");
+ pending = TRUE;
+ } else if (http_client_get_pending_request_count(http_client3) > 0) {
+ i_debug("Requests still pending in client 3");
+ pending = TRUE;
+ } else if (http_client_get_pending_request_count(http_client4) > 0) {
+ i_debug("Requests still pending in client 4");
+ pending = TRUE;
+ }
+ if (!pending)
+ break;
+ io_loop_run(ioloop);
+ }
+ http_client_deinit(&http_client1);
+ http_client_deinit(&http_client2);
+ http_client_deinit(&http_client3);
+ http_client_deinit(&http_client4);
+
+ http_client_context_unref(&http_cctx);
dns_client_deinit(&dns_client);