diff options
author | Azat Khuzhin <a3at.mail@gmail.com> | 2014-09-21 18:36:29 +0400 |
---|---|---|
committer | Azat Khuzhin <a3at.mail@gmail.com> | 2014-09-21 23:48:07 +0400 |
commit | d9da844369817a58d3f9eb10efc0be07f0a046b8 (patch) | |
tree | e986c0e49c56f32e1afe7ce138ce3e66e6b82596 | |
parent | 07b5e45ba53182bf61a3eee6cef57d48ef776111 (diff) | |
download | libevent-d9da844369817a58d3f9eb10efc0be07f0a046b8.tar.gz |
https-client: add -retries argument, for connection retries
Using evhttp_connection_set_retries() API.
-rw-r--r-- | sample/https-client.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sample/https-client.c b/sample/https-client.c index b5f0b1ae..eea61e5d 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -96,7 +96,7 @@ static void syntax(void) { fputs("Syntax:\n", stderr); - fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert]\n", stderr); + fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num]\n", stderr); fputs("Example:\n", stderr); fputs(" https-client -url https://ip.appspot.com/\n", stderr); @@ -195,6 +195,7 @@ main(int argc, char **argv) const char *scheme, *host, *path, *query; char uri[256]; int port; + int retries = 0; SSL_CTX *ssl_ctx; SSL *ssl; @@ -221,6 +222,12 @@ main(int argc, char **argv) } else { syntax(); } + } else if (!strcmp("-retries", argv[i])) { + if (i < argc - 1) { + retries = atoi(argv[i + 1]); + } else { + syntax(); + } } else if (!strcmp("-help", argv[i])) { syntax(); } @@ -373,6 +380,10 @@ main(int argc, char **argv) return 1; } + if (retries > 0) { + evhttp_connection_set_retries(evcon, retries); + } + // Fire off the request req = evhttp_request_new(http_request_done, bev); if (req == NULL) { |