+static struct progress pmt;
+static struct uloop_timeout pmt_timer;
+
+static int init_request(struct uclient *cl);
+static void request_done(struct uclient *cl);
+
+static void pmt_update(struct uloop_timeout *t)
+{
+ progress_update(&pmt, out_offset, out_bytes, out_len);
+ uloop_timeout_set(t, 1000);
+}
+
+static const char *
+get_proxy_url(char *url)
+{
+ char prefix[16];
+ char *sep;
+
+ if (!proxy)
+ return NULL;
+
+ sep = strchr(url, ':');
+ if (!sep)
+ return NULL;
+
+ if (sep - url > 5)
+ return NULL;
+
+ memcpy(prefix, url, sep - url);
+ strcpy(prefix + (sep - url), "_proxy");
+ return getenv(prefix);
+}
+
+static int open_output_file(const char *path, uint64_t resume_offset)