syntax(void)
{
fputs("Syntax:\n", stderr);
- fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num]\n", stderr);
+ fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec]\n", stderr);
fputs("Example:\n", stderr);
fputs(" https-client -url https://ip.appspot.com/\n", stderr);
}
char uri[256];
int port;
int retries = 0;
+ int timeout = -1;
SSL_CTX *ssl_ctx = NULL;
SSL *ssl = NULL;
syntax();
goto error;
}
+ } else if (!strcmp("-timeout", argv[i])) {
+ if (i < argc - 1) {
+ timeout = atoi(argv[i + 1]);
+ } else {
+ syntax();
+ goto error;
+ }
} else if (!strcmp("-help", argv[i])) {
syntax();
goto error;
if (retries > 0) {
evhttp_connection_set_retries(evcon, retries);
}
+ if (timeout >= 0) {
+ evhttp_connection_set_timeout(evcon, timeout);
+ }
// Fire off the request
req = evhttp_request_new(http_request_done, bev);