Re: [PATCH v2] http.c: use CURLOPT_RANGE for range requests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> Jeff King <peff@xxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]