From 3c6c79a637d34458db6a3530da34fb47c73c0e3f Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Tue, 20 Mar 2007 10:27:21 +0200 Subject: [PATCH] show_http_error_document: Generate a charset parameter. --- src/protocol/http/codes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/protocol/http/codes.c b/src/protocol/http/codes.c index 8fbc1dc0..e0740eae 100644 --- a/src/protocol/http/codes.c +++ b/src/protocol/http/codes.c @@ -169,8 +169,21 @@ show_http_error_document(struct session *ses, void *data) if (cache) str = get_http_error_document(term, info->uri, info->code); if (str) { + /* The codepage that _("foo", term) used when it was + * called by get_http_error_document. */ + const int gettext_codepage + = get_opt_codepage_tree(term->spec, "charset"); + if (cached) delete_entry_content(cache); + + /* If we run out of memory here, it's perhaps better + * to display a malformatted error message than none + * at all. */ mem_free_set(&cache->content_type, stracpy("text/html")); + mem_free_set(&cache->head, + straconcat("\r\nContent-Type: text/html; charset=", + get_cp_mime_name(gettext_codepage), + "\r\n", (unsigned char *) NULL)); add_fragment(cache, 0, str, strlen(str)); mem_free(str);