+static void generate_header(struct connection *conn,
+ const int code, const char *text)
+{
+ char date[DATE_LEN];
+
+ assert(conn->header == NULL);
+ assert(conn->mime_type != NULL);
+ if (conn->encoding == NULL)
+ conn->encoding = encoding_identity;
+
+ verbosef("http: %d %s (%s: %d bytes)", code, text,
+ conn->encoding, conn->reply_length);
+ conn->header_length = xasprintf(&(conn->header),
+ "HTTP/1.1 %d %s\r\n"
+ "Date: %s\r\n"
+ "Server: %s\r\n"
+ "Vary: Accept-Encoding\r\n"
+ "Content-Type: %s\r\n"
+ "Content-Length: %d\r\n"
+ "Content-Encoding: %s\r\n"
+ "%s"
+ "\r\n"
+ ,
+ code, text,
+ rfc1123_date(date, now), server,
+ conn->mime_type, conn->reply_length, conn->encoding,
+ conn->header_extra);
+ conn->http_code = code;
+}
+