mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 14:26:30 -04:00
https-client: add -retries argument, for connection retries
Using evhttp_connection_set_retries() API.
This commit is contained in:
parent
07b5e45ba5
commit
d9da844369
@ -96,7 +96,7 @@ static void
|
|||||||
syntax(void)
|
syntax(void)
|
||||||
{
|
{
|
||||||
fputs("Syntax:\n", stderr);
|
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("Example:\n", stderr);
|
||||||
fputs(" https-client -url https://ip.appspot.com/\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;
|
const char *scheme, *host, *path, *query;
|
||||||
char uri[256];
|
char uri[256];
|
||||||
int port;
|
int port;
|
||||||
|
int retries = 0;
|
||||||
|
|
||||||
SSL_CTX *ssl_ctx;
|
SSL_CTX *ssl_ctx;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
@ -221,6 +222,12 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
syntax();
|
syntax();
|
||||||
}
|
}
|
||||||
|
} else if (!strcmp("-retries", argv[i])) {
|
||||||
|
if (i < argc - 1) {
|
||||||
|
retries = atoi(argv[i + 1]);
|
||||||
|
} else {
|
||||||
|
syntax();
|
||||||
|
}
|
||||||
} else if (!strcmp("-help", argv[i])) {
|
} else if (!strcmp("-help", argv[i])) {
|
||||||
syntax();
|
syntax();
|
||||||
}
|
}
|
||||||
@ -373,6 +380,10 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retries > 0) {
|
||||||
|
evhttp_connection_set_retries(evcon, retries);
|
||||||
|
}
|
||||||
|
|
||||||
// Fire off the request
|
// Fire off the request
|
||||||
req = evhttp_request_new(http_request_done, bev);
|
req = evhttp_request_new(http_request_done, bev);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user