couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r729694 - in /couchdb/branches/form: share/www/script/couch_tests.js src/couchdb/couch_httpd_external.erl
Date Sat, 27 Dec 2008 23:27:10 GMT
Author: jchris
Date: Sat Dec 27 15:27:09 2008
New Revision: 729694

URL: http://svn.apache.org/viewvc?rev=729694&view=rev
Log:
forms and external can return binary data

Modified:
    couchdb/branches/form/share/www/script/couch_tests.js
    couchdb/branches/form/src/couchdb/couch_httpd_external.erl

Modified: couchdb/branches/form/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/branches/form/share/www/script/couch_tests.js?rev=729694&r1=729693&r2=729694&view=diff
==============================================================================
--- couchdb/branches/form/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/branches/form/share/www/script/couch_tests.js [utf-8] Sat Dec 27 15:27:09 2008
@@ -1880,7 +1880,8 @@
          "accept-switch" : (function(doc, req) {
            if (req.headers["Accept"].match(/image/)) {
              return {
-               "body" : "accepting image requests",
+               // a 16x16 px version of the CouchDB logo
+               "base64" : "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAsVBMVEUAAAD////////////////////////5ur3rEBn////////////////wDBL/AADuBAe9EB3IEBz/7+//X1/qBQn2AgP/f3/ilpzsDxfpChDtDhXeCA76AQH/v7/84eLyWV/uc3bJPEf/Dw/uw8bRWmP1h4zxSlD6YGHuQ0f6g4XyQkXvCA36MDH6wMH/z8/yAwX64ODeh47BHiv/Ly/20dLQLTj98PDXWmP/Pz//39/wGyJ7Iy9JAAAADHRSTlMAbw8vf08/bz+Pv19jK/W3AAAAg0lEQVR4Xp3LRQ4DQRBD0QqTm4Y5zMxw/4OleiJlHeUtv2X6RbNO1Uqj9g0RMCuQO0vBIg4vMFeOpCWIWmDOw82fZxvaND1c8OG4vrdOqD8YwgpDYDxRgkSm5rwu0nQVBJuMg++pLXZyr5jnc1BaH4GTLvEliY253nA3pVhQqdPt0f/erJkMGMB8xucAAAAASUVORK5CYII=",
                headers : {
                  "Content-Type" : "image/png",
                  "Vary" : "Accept" // we set this for proxy caches
@@ -1950,11 +1951,9 @@
      xhr = CouchDB.request("GET", "/test_suite_db/_form/missingdoc/just-name/"+docid);
      T(xhr.status == 404);
      var resp = JSON.parse(xhr.responseText);
-     console.log(resp)
      T(resp.error == "not_found");
      T(resp.reason == "missing_design_doc");
      
-     
      // query parameters
      xhr = CouchDB.request("GET", "/test_suite_db/_form/template/req-info/"+docid+"?foo=bar",
{
        headers: {
@@ -1983,10 +1982,11 @@
      T("text/html" == xhr.getResponseHeader("Content-Type"));
      T("Accept" == xhr.getResponseHeader("Vary"));
      var etag = xhr.getResponseHeader("etag");
-     
+
      xhr = CouchDB.request("GET", "/test_suite_db/_form/template/accept-switch/"+docid, {
        headers: {"Accept": "image/png;*/*"}
      });
+     T(xhr.responseText.match(/PNG/))
      T("image/png" == xhr.getResponseHeader("Content-Type"));
      var etag2 = xhr.getResponseHeader("etag");
      T(etag2 != etag);

Modified: couchdb/branches/form/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/form/src/couchdb/couch_httpd_external.erl?rev=729694&r1=729693&r2=729694&view=diff
==============================================================================
--- couchdb/branches/form/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/branches/form/src/couchdb/couch_httpd_external.erl Sat Dec 27 15:27:09 2008
@@ -120,6 +120,8 @@
                     ctype="application/json"};
             {<<"body">>, Value} ->
                 Args#extern_resp_args{data=Value, ctype="text/html"};
+            {<<"base64">>, Value} ->
+                Args#extern_resp_args{data=couch_util:decodeBase64(Value), ctype="application/binary"};
             {<<"headers">>, {Headers}} ->
                 NewHeaders = lists:map(fun({Header, HVal}) ->
                     {binary_to_list(Header), binary_to_list(HVal)}



Mime
View raw message