From 887955a951470a9dc211c6e404905292f1a39585 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Sat, 4 Jul 2009 16:19:23 +0000 Subject: send utf-8 hearders with list and show responses. closes COUCHDB-392 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791145 13f79535-47bb-0310-9956-ffa450edef68 --- share/server/render.js | 4 ++-- share/www/script/test/list_views.js | 2 +- share/www/script/test/show_documents.js | 16 +++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'share') diff --git a/share/server/render.js b/share/server/render.js index 99541eab..b3a24bde 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -166,8 +166,8 @@ registerType = function() { // http://dev.rubyonrails.org/svn/rails/trunk/actionpack/lib/action_controller/mime_types.rb registerType("all", "*/*"); -registerType("text", "text/plain", "txt"); -registerType("html", "text/html"); +registerType("text", "text/plain; charset=utf-8", "txt"); +registerType("html", "text/html; charset=utf-8"); registerType("xhtml", "application/xhtml+xml", "xhtml"); registerType("xml", "application/xml", "text/xml", "application/x-xml"); registerType("js", "text/javascript", "application/javascript", "application/x-javascript"); diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js index 2b7e4cb3..bbe0814c 100644 --- a/share/www/script/test/list_views.js +++ b/share/www/script/test/list_views.js @@ -312,7 +312,7 @@ couchTests.list_views = function(debug) { "Accept": 'text/html' } }); - T(xhr.getResponseHeader("Content-Type") == "text/html"); + T(xhr.getResponseHeader("Content-Type") == "text/html; charset=utf-8"); T(xhr.responseText.match(/HTML/)); T(xhr.responseText.match(/Value/)); diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js index 18dcc0b3..64a6788f 100644 --- a/share/www/script/test/show_documents.js +++ b/share/www/script/test/show_documents.js @@ -143,10 +143,7 @@ couchTests.show_documents = function(debug) { // hello template world xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/"+docid); T(xhr.responseText == "Hello World"); -// -// }; -// -// function foo() { + T(/charset=utf-8/.test(xhr.getResponseHeader("Content-Type"))) // Fix for COUCHDB-379 T(equals(xhr.getResponseHeader("Server").substr(0,7), "CouchDB")); @@ -207,7 +204,8 @@ couchTests.show_documents = function(debug) { xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/accept-switch/"+docid, { headers: {"Accept": "text/html;text/plain;*/*"} }); - T("text/html" == xhr.getResponseHeader("Content-Type")); + var ct = xhr.getResponseHeader("Content-Type"); + T(/text\/html/.test(ct)) T("Accept" == xhr.getResponseHeader("Vary")); var etag = xhr.getResponseHeader("etag"); @@ -287,7 +285,9 @@ couchTests.show_documents = function(debug) { "Accept": 'text/html,application/atom+xml; q=0.9' } }); - T(xhr.getResponseHeader("Content-Type") == "text/html"); + var ct = xhr.getResponseHeader("Content-Type"); + T(/charset=utf-8/.test(ct)) + T(/text\/html/.test(ct)) T(xhr.responseText == "Ha ha, you said \"plankton\"."); // now with xml @@ -315,7 +315,9 @@ couchTests.show_documents = function(debug) { "Accept": 'text/html,application/atom+xml; q=0.9' } }); - T(xhr.getResponseHeader("Content-Type") == "text/html"); + var ct = xhr.getResponseHeader("Content-Type"); + T(/charset=utf-8/.test(ct)) + T(/text\/html/.test(ct)) T(xhr.responseText == "Ha ha, you said \"plankton\"."); // test inclusion of conflict state -- cgit v1.2.3