X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=uclient-fetch.c;h=7418f823122653d2295814cf03df8a754c20f5f6;hb=b94caa406f4e5c1db4691735ba4969b002dc978f;hp=d4b95274310bc8a157fde4e37f564488764b0eef;hpb=3515604cfb0ba9fbb94289869df8692145229d38;p=project%2Fuclient.git diff --git a/uclient-fetch.c b/uclient-fetch.c index d4b9527..7418f82 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -52,6 +52,7 @@ static char *password; static char *auth_str; static char **urls; static int n_urls; +static int timeout; static void request_done(struct uclient *cl); @@ -158,6 +159,9 @@ static int init_request(struct uclient *cl) out_bytes = 0; uclient_http_set_ssl_ctx(cl, ssl_ops, ssl_ctx, verify); + if (timeout) + cl->timeout_msecs = timeout * 1000; + rc = uclient_connect(cl); if (rc) return rc; @@ -271,6 +275,7 @@ static int usage(const char *progname) " --user-agent|-U Set HTTP user agent\n" " --post-data=STRING use the POST method; send STRING as the data\n" " --spider|-s Spider mode - only check file existence\n" + " --timeout=N|-T N Set connect/request timeout to N seconds\n" "\n" "HTTPS options:\n" " --ca-certificate=: Load CA certificates from file \n" @@ -318,6 +323,7 @@ enum { L_USER_AGENT, L_POST_DATA, L_SPIDER, + L_TIMEOUT, }; static const struct option longopts[] = { @@ -328,6 +334,7 @@ static const struct option longopts[] = { [L_USER_AGENT] = { "user-agent", required_argument }, [L_POST_DATA] = { "post-data", required_argument }, [L_SPIDER] = { "spider", no_argument }, + [L_TIMEOUT] = { "timeout", required_argument }, {} }; @@ -377,6 +384,9 @@ int main(int argc, char **argv) case L_SPIDER: no_output = true; break; + case L_TIMEOUT: + timeout = atoi(optarg); + break; default: return usage(progname); } @@ -393,6 +403,9 @@ int main(int argc, char **argv) case 's': no_output = true; break; + case 'T': + timeout = atoi(optarg); + break; default: return usage(progname); }