You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ns...@apache.org on 2009/02/24 19:10:20 UTC

svn commit: r747465 - in /couchdb/trunk: share/www/script/test/config.js share/www/script/test/content_negotiation.js src/couchdb/couch_httpd.erl

Author: nslater
Date: Tue Feb 24 18:10:19 2009
New Revision: 747465

URL: http://svn.apache.org/viewvc?rev=747465&view=rev
Log:
added newline to JSON responses, closes COUCHDB-107

Modified:
    couchdb/trunk/share/www/script/test/config.js
    couchdb/trunk/share/www/script/test/content_negotiation.js
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/share/www/script/test/config.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/config.js?rev=747465&r1=747464&r2=747465&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/config.js (original)
+++ couchdb/trunk/share/www/script/test/config.js Tue Feb 24 18:10:19 2009
@@ -15,7 +15,7 @@
   db.deleteDb();
   db.createDb();
   if (debug) debugger;
-  
+
   // test that /_config returns all the settings
   var xhr = CouchDB.request("GET", "/_config");
   var config = JSON.parse(xhr.responseText);
@@ -49,7 +49,7 @@
   T(config.httpd_global_handlers._config);
   T(config.log.level);
   T(config.query_servers.javascript);
-  
+
   // test that settings can be altered
   xhr = CouchDB.request("PUT", "/_config/test/foo",{
     body : JSON.stringify("bar"),
@@ -62,5 +62,6 @@
 
   // you can get a single key
   xhr = CouchDB.request("GET", "/_config/test/foo");
-  T(xhr.responseText == '"bar"');
+  config = JSON.parse(xhr.responseText);
+  T(config == "bar");
 };

Modified: couchdb/trunk/share/www/script/test/content_negotiation.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/content_negotiation.js?rev=747465&r1=747464&r2=747465&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/content_negotiation.js (original)
+++ couchdb/trunk/share/www/script/test/content_negotiation.js Tue Feb 24 18:10:19 2009
@@ -20,6 +20,10 @@
   xhr = CouchDB.request("GET", "/test_suite_db/");
   T(xhr.getResponseHeader("Content-Type") == "text/plain;charset=utf-8");
 
+  // make sure JSON responses end in a newline
+  var text = xhr.responseText;
+  T(text[text.length-1] == "\n");
+
   xhr = CouchDB.request("GET", "/test_suite_db/", {
     headers: {"Accept": "text/html;text/plain;*/*"}
   });

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=747465&r1=747464&r2=747465&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Tue Feb 24 18:10:19 2009
@@ -367,7 +367,8 @@
         {"Content-Type", negotiate_content_type(Req)},
         {"Cache-Control", "must-revalidate"}
     ],
-    send_response(Req, Code, DefaultHeaders ++ Headers, ?JSON_ENCODE(Value)).
+    send_response(Req, Code, DefaultHeaders ++ Headers,
+                  list_to_binary([?JSON_ENCODE(Value), $\n])).
 
 start_json_response(Req, Code) ->
     start_json_response(Req, Code, []).
@@ -380,6 +381,7 @@
     start_chunked_response(Req, Code, DefaultHeaders ++ Headers).
 
 end_json_response(Resp) ->
+    send_chunk(Resp, [$\n]),
     send_chunk(Resp, []).