Re: [RFC 2/2] Add Git-aware CGI for Git-aware smart HTTP transport
- From
- H. Peter Anvin <hpa@zytor.com>
- Date
- Aug 3, 2008, 11:38 UTC
- Message-ID
- <489598C5.6060508@zytor.com>
- In-Reply-To
- <1217748317-70096-2-git-send-email-spearce@spearce.org>
Shawn O. Pearce wrote:
Show 31 quoted lines
> +#define hex(a) (hexchar[(a) & 15])
> +static void chunked_write(const char *fmt, ...)
> +{
> + static const char hexchar[] = "0123456789abcdef";
> + va_list args;
> + unsigned n;
> +
> + va_start(args, fmt);
> + n = vsnprintf(buffer + 6, sizeof(buffer) - 8, fmt, args);
> + va_end(args);
> + if (n >= sizeof(buffer) - 8)
> + die("protocol error: impossibly long line");
> +
> + if (can_chunk) {
> + unsigned len = n + 4, b = 4;
> +
> + buffer[4] = '\r';
> + buffer[5] = '\n';
> + buffer[n + 6] = '\r';
> + buffer[n + 7] = '\n';
> +
> + while (n > 0) {
> + buffer[--b] = hex(n);
> + n >>= 4;
> + len++;
> + }
> +
> + safe_write(1, buffer + b, len);
> + } else
> + safe_write(1, buffer + 6, n);
> +}Maybe I am slightly confused, but I thought handling HTTP chunking for HTTP/1.1+ clients was usually done by Apache above the level of the CGI script?
-hpa