struct _connection_refused {
unsigned int count;
+ struct timeout *to;
};
static void
const struct http_response *resp,
struct _connection_refused *ctx)
{
+ test_assert(ctx->to == NULL);
+ if (ctx->to != NULL)
+ timeout_remove(&ctx->to);
+
if (debug)
i_debug("RESPONSE: %u %s", resp->status, resp->reason);
}
}
+static void
+test_client_connection_refused_timeout(struct _connection_refused *ctx)
+{
+ if (debug)
+ i_debug("TIMEOUT (ok)");
+ timeout_remove(&ctx->to);
+}
+
static bool
test_client_connection_refused(const struct http_client_settings *client_set)
{
ctx = i_new(struct _connection_refused, 1);
ctx->count = 2;
+ if (client_set->max_connect_attempts > 0) {
+ ctx->to = timeout_add_short(250,
+ test_client_connection_refused_timeout, ctx);
+ }
+
http_client = http_client_init(client_set);
hreq = http_client_request(http_client,
test_server_connection_refused, 1,
NULL);
test_end();
+
+ http_client_set.max_connect_attempts = 3;
+
+ test_begin("connection refused backoff");
+ test_run_client_server(&http_client_set,
+ test_client_connection_refused,
+ test_server_connection_refused, 1,
+ NULL);
+ test_end();
}
/*