couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nsla...@apache.org
Subject svn commit: r747465 - in /couchdb/trunk: share/www/script/test/config.js share/www/script/test/content_negotiation.js src/couchdb/couch_httpd.erl
Date Tue, 24 Feb 2009 18:10:20 GMT
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, []).
 
 



Mime
View raw message