+
+ rc = uclient_http_set_request_type(cl, post_data ? "POST" : "GET");
+ if (rc)
+ return rc;
+
+ uclient_http_reset_headers(cl);
+ uclient_http_set_header(cl, "User-Agent", user_agent);
+ if (cur_resume)
+ check_resume_offset(cl);
+
+ if (post_data) {
+ uclient_http_set_header(cl, "Content-Type", "application/x-www-form-urlencoded");
+ uclient_write(cl, post_data, strlen(post_data));
+ }
+
+ rc = uclient_request(cl);
+ if (rc)
+ return rc;
+
+ return 0;
+}
+
+static void request_done(struct uclient *cl)
+{
+ const char *proxy_url;
+
+ if (n_urls) {
+ proxy_url = get_proxy_url(*urls);
+ if (proxy_url) {
+ uclient_set_url(cl, proxy_url, NULL);
+ uclient_set_proxy_url(cl, *urls, auth_str);
+ } else {
+ uclient_set_url(cl, *urls, auth_str);
+ }
+ n_urls--;
+ cur_resume = resume;
+ error_ret = init_request(cl);
+ if (error_ret == 0)
+ return;
+ }
+
+ if (output_fd >= 0 && !opt_output_file) {
+ close(output_fd);
+ output_fd = -1;
+ }
+ uclient_disconnect(cl);
+ uloop_end();