if (debug) log_d("D output_headers");
static int output_headers(struct pool *p, struct request *r){	long cl;	char tmp_outbuf[2048], gbuf[40], *b;	unsigned long port;	if (debug)		log_d("D output_headers");	if (r->cn->assbackwards)		return 0;	b = tmp_outbuf;	b += sprintf(b, "HTTP/%d.%d %s\r\n"		"Server: %s\r\n"		"Date: %s\r\n",		r->protocol_major, r->protocol_minor, r->status_line,		server_version,		rfctime(current_time, gbuf));	if (r->allowedmethods)		b += sprintf(b, "Allow: %s\r\n", r->allowedmethods);	if (r->c && r->c->realm && r->status == 401)		b += sprintf(b, "WWW-Authenticate: Basic realm=\"%s\"\r\n", r->c->realm);	if (r->num_content >= 0) {		b += sprintf(b, "Content-type: %s\r\n", r->content_type);		cl = r->content_length;		if (cl >= 0)			b += sprintf(b, "Content-length: %ld\r\n", cl);		if (r->last_modified)			b += sprintf(b, "Last-Modified: %s\r\n", rfctime(r->last_modified, gbuf));	}	if (r->location) {		if (r->location[0] == '/' && r->servername) {			port = r->cn->s->port;			if (port == 80)				b += sprintf(b, "Location: http://%s%.512s\r\n", r->servername, r->location);			else				b += sprintf(b, "Location: http://%s:%lu%.512s\r\n", r->servername, port, r->location);		} else			b += sprintf(b, "Location: %.512s\r\n", r->location);	}	if (r->cn->keepalive) {		if (r->protocol_minor == 0)			b += sprintf(b, "Connection: Keep-Alive\r\n");	} else if (r->protocol_minor)		b += sprintf(b, "Connection: Close\r\n");	b += sprintf(b, "\r\n");	return putstring(p, tmp_outbuf);}