From: Junio C Hamano Date: Sat, 31 Oct 2015 17:40:13 GMT Subject: Re: [PATCH v2] http.c: use CURLOPT_RANGE for range requests Message-ID: In-Reply-To: <20151031000837.GA25849@sigill.intra.peff.net> Jeff King 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 ;-)