From: Junio C Hamano <gitster@pobox.com>
To: Kevin Wern <kevin.m.wern@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 07/11] Resumable clone: add resumable download to http/curl
Date: Fri, 16 Sep 2016 15:45:44 -0700 [thread overview]
Message-ID: <xmqqfuozihuv.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1473984742-12516-8-git-send-email-kevin.m.wern@gmail.com> (Kevin Wern's message of "Thu, 15 Sep 2016 20:12:18 -0400")
Kevin Wern <kevin.m.wern@gmail.com> writes:
> +int http_download_primer(const char *url, const char *out_file)
> +{
> + int ret = 0, try_count = HTTP_TRY_COUNT;
> + struct http_get_options options = {0};
> + options.progress = 1;
> +
> + if (file_exists(out_file)) {
> + fprintf(stderr,
> + "File already downloaded: '%s', skipping...\n",
> + out_file);
> + return ret;
> + }
> +
> + do {
> + if (try_count != HTTP_TRY_COUNT) {
> + fprintf(stderr, "Connection interrupted for some "
> + "reason, retrying (%d attempts left)\n",
> + try_count);
> + struct timeval time = {10, 0}; // 1s
We do not use // comment.
> + select(0, NULL, NULL, NULL, &time);
> + }
> + ret = http_get_file(url, out_file, &options);
I didn't realize that http_get_file() -> http_request() codepath,
when it is the output file, already can do the "ftell and request
the reminder". Very nice.
> @@ -1136,7 +1138,10 @@ static int handle_curl_result(struct slot_results *results)
> curl_easy_strerror(results->curl_result),
> sizeof(curl_errorstr));
> #endif
> - return HTTP_ERROR;
> + if (results->http_code >= 400)
> + return HTTP_ERROR;
> + else
> + return HTTP_ERROR_RESUMABLE;
> }
> }
Hmm, is "anything below 400" a good definition of resumable errors?
next prev parent reply other threads:[~2016-09-16 22:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 0:12 [PATCH 00/11] Resumable clone Kevin Wern
2016-09-16 0:12 ` [PATCH 01/11] Resumable clone: create service git-prime-clone Kevin Wern
2016-09-16 20:53 ` Junio C Hamano
2016-09-28 4:40 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 02/11] Resumable clone: add prime-clone endpoints Kevin Wern
2016-09-19 13:15 ` Duy Nguyen
2016-09-28 4:43 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 03/11] pkt-line: create gentle packet_read_line functions Kevin Wern
2016-09-16 22:17 ` Junio C Hamano
2016-09-28 4:42 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 04/11] Resumable clone: add prime-clone to remote-curl Kevin Wern
2016-09-19 13:52 ` Duy Nguyen
2016-09-28 6:45 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 05/11] Resumable clone: add output parsing to connect.c Kevin Wern
2016-09-16 0:12 ` [PATCH 06/11] Resumable clone: implement transport_prime_clone Kevin Wern
2016-09-16 0:12 ` [PATCH 07/11] Resumable clone: add resumable download to http/curl Kevin Wern
2016-09-16 22:45 ` Junio C Hamano [this message]
2016-09-28 6:41 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 08/11] Resumable clone: create transport_download_primer Kevin Wern
2016-09-16 0:12 ` [PATCH 09/11] path: add resumable marker Kevin Wern
2016-09-19 13:24 ` Duy Nguyen
2016-09-16 0:12 ` [PATCH 10/11] run command: add RUN_COMMAND_NO_STDOUT Kevin Wern
2016-09-16 23:07 ` Junio C Hamano
2016-09-18 19:22 ` Johannes Schindelin
2016-09-28 4:46 ` Kevin Wern
2016-09-28 17:54 ` Junio C Hamano
2016-09-28 18:06 ` Kevin Wern
2016-09-16 0:12 ` [PATCH 11/11] Resumable clone: implement primer logic in git-clone Kevin Wern
2016-09-16 23:32 ` Junio C Hamano
2016-09-28 5:49 ` Kevin Wern
2016-09-19 14:04 ` Duy Nguyen
2016-09-19 17:16 ` Junio C Hamano
2016-09-28 4:44 ` Kevin Wern
2016-09-16 20:47 ` [PATCH 00/11] Resumable clone Junio C Hamano
2016-09-27 21:51 ` Eric Wong
2016-09-27 22:07 ` Junio C Hamano
2016-09-28 17:32 ` Junio C Hamano
2016-09-28 18:22 ` Junio C Hamano
2016-09-28 20:46 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfuozihuv.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kevin.m.wern@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.