git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Turner <dturner@twopensource.com>, git@vger.kernel.org
Subject: Re: [PATCH v2] http.c: use CURLOPT_RANGE for range requests
Date: Sat, 31 Oct 2015 13:43:12 -0400	[thread overview]
Message-ID: <20151031174312.GA2962@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqfv0rhr7m.fsf@gitster.mtv.corp.google.com>

On Sat, Oct 31, 2015 at 10:40:13AM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > We could even hide the whole thing away with something like:
> >
> >   void http_set_range(CURL *curl, long lo, long hi)
> >   {
> > 	char buf[128];
> > 	int len = 0;
> >
> > 	if (lo >= 0)
> > 		len += xsnprintf(buf + len, "%ld", lo);
> > 	len += xsnprintf(buf + len, "-");
> > 	if (hi >= 0)
> > 		len += xsnprintf(buf + len, "%ld", hi);
> >
> > 	curl_easy_setopt(curl, CURLOPT_RANGE, buf);
> >   }
> >
> > That would also make it easier to replace if we do need to keep an
> > #ifdef for older versions of curl. But maybe it is just
> > over-engineering.
> 
> I personally do not think this is an over-engineered version.  This
> is exactly what I had in mind when I alluded to a small helper ;-)

Yeah, I somehow missed your suggestion before writing that. I think the
important thing your example noted is that we would always pass -1 for
"hi" in all the current callers, so we can simplify this quite a bit,
and use only one snprintf.

-Peff

  reply	other threads:[~2015-10-31 17:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 22:54 [PATCH v2] http.c: use CURLOPT_RANGE for range requests David Turner
2015-10-30 23:13 ` Junio C Hamano
2015-10-31  0:08 ` Jeff King
2015-10-31 17:40   ` Junio C Hamano
2015-10-31 17:43     ` Jeff King [this message]
2015-11-01 23:00   ` Daniel Stenberg
2015-11-02  1:51     ` Jeff King
2015-11-02  7:05       ` Daniel Stenberg

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=20151031174312.GA2962@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).