diff options
author | Felix Fietkau <nbd@openwrt.org> | 2016-01-23 01:23:00 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2016-01-23 01:23:00 +0100 |
commit | 4924411cff2e74d835b819151513367d08c9e524 (patch) | |
tree | 54f6f71817b9a7bf81900b96a5a3b7d78997402d /uclient-fetch.c | |
parent | b9808a8c3a8922ed8df4e6fe45848ac2e52f13be (diff) | |
download | uclient-4924411cff2e74d835b819151513367d08c9e524.tar.gz |
http: add proper error handling to uclient_http_redirect()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-fetch.c')
-rw-r--r-- | uclient-fetch.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/uclient-fetch.c b/uclient-fetch.c index 223d364..d2ffde3 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -165,12 +165,22 @@ static void header_done_cb(struct uclient *cl) uint64_t resume_offset = 0, resume_end, resume_size; static int retries; - if (retries < 10 && uclient_http_redirect(cl)) { - if (!quiet) - fprintf(stderr, "Redirected to %s on %s\n", cl->url->location, cl->url->host); + if (retries < 10) { + int ret = uclient_http_redirect(cl); + if (ret < 0) { + if (!quiet) + fprintf(stderr, "Failed to redirect to %s on %s\n", cl->url->location, cl->url->host); + error_ret = 8; + request_done(cl); + return; + } + if (ret > 0) { + if (!quiet) + fprintf(stderr, "Redirected to %s on %s\n", cl->url->location, cl->url->host); - retries++; - return; + retries++; + return; + } } if (cl->status_code == 204 && cur_resume) { |