if (debug) log_d("D prepare_reply");
int prepare_reply(struct request *r){	struct pool *p;	char *b, buf[PATHLEN];	int send_message;	send_message = r->method != M_HEAD;	if (r->status >= 400)		r->last_modified = 0;	switch (r->status) {	case 200:		r->status_line = "200 OK";		send_message = 0;		break;	case 204:		r->status_line = "204 No Content";		send_message = 0;		break;	case 302:		r->status_line = "302 Moved";		break;	case 304:		r->status_line = "304 Not Modified";		send_message = 0;		break;	case 400:		r->status_line = "400 Bad Request";		break;	case 401:		r->status_line = "401 Not Authorized";		break;	case 403:		r->status_line = "403 Forbidden";		break;	case 404:		r->status_line = "404 Not Found";		break;	case 405:		r->status_line = "405 Method Not Allowed";		r->allowedmethods = "GET, HEAD";		break;	case 501:		r->status_line = "501 Not Implemented";		break;	case 503:		r->status_line = "503 Service Unavailable";		break;	case 505:		r->status_line = "505 HTTP Version Not Supported";		break;	default:		r->status_line = "500 Internal Server Error";		break;	}	if (r->error_file) {		if (send_message && add_fd(r, r->error_file) != -1)			send_message = 0;	}	if (send_message) {		b = buf;		b += sprintf(b, "<title>%s</title>\n"			"<h1>%s</h1>\n", r->status_line, r->status_line);		switch (r->status) {		case 302:			b += sprintf(b, "This document has moved to URL <a href=\"%s\">%s</a>.\n", r->location, r->location);			break;		case 401:			b += sprintf(b, "You need proper authorization to use this resource.\n");			break;		case 400:		case 405:		case 501:		case 505:			b += sprintf(b, "Your request was not understood or not allowed by this server.\n");			break;		case 403:			b += sprintf(b, "Access to this resource has been denied to you.\n");			break;		case 404:			b += sprintf(b, "The resource requested could not be found on this server.\n");			break;		case 503:			b += sprintf(b, "The server is temporarily busy.\n");			break;		default:			b += sprintf(b, "An internal server error has occurred.\n");			break;		}		if (r->c && r->c->admin)			b += sprintf(b, "<p>Please contact the site administrator at <i>%s</i>.\n", r->c->admin);		r->content_length = strlen(buf);		r->num_content = 0;		r->content_type = "text/html";	}	if (r->status >= 400 && r->method != M_GET && r->method != M_HEAD)		r->cn->keepalive = 0;	p = r->cn->output;	return (output_headers(p, r) == -1 || (send_message && putstring(p, buf) == -1)) ? -1 : 0;}