You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2009/09/15 15:04:11 UTC

svn commit: r815308 - in /couchdb/trunk: share/www/script/test/attachments.js src/couchdb/couch_httpd_db.erl

Author: jan
Date: Tue Sep 15 13:04:10 2009
New Revision: 815308

URL: http://svn.apache.org/viewvc?rev=815308&view=rev
Log:
fix attachments with an undefined Content-Length header and no TE, patch by Benoit Chesneau, closes COUCHDB-497

Modified:
    couchdb/trunk/share/www/script/test/attachments.js
    couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/share/www/script/test/attachments.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/attachments.js?rev=815308&r1=815307&r2=815308&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/attachments.js (original)
+++ couchdb/trunk/share/www/script/test/attachments.js Tue Sep 15 13:04:10 2009
@@ -225,4 +225,16 @@
     headers: {"if-none-match": etag}
   });
   T(xhr.status == 304);
+
+  // test COUCHDB-497 - empty attachments
+  var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc5/empty.txt?rev="+rev, {
+    headers:{"Content-Type":"text/plain;charset=utf-8", "Content-Length": "0"},
+    body:""
+  });
+  TEquals(201, xhr.status, "should send 201 Accepted");
+  var rev = JSON.parse(xhr.responseText).rev;
+  var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc5/empty.txt?rev="+rev, {
+    headers:{"Content-Type":"text/plain;charset=utf-8"}
+  });
+  TEquals(201, xhr.status, "should send 201 Accepted");
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=815308&r1=815307&r2=815308&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Tue Sep 15 13:04:10 2009
@@ -895,7 +895,7 @@
                     end,
                 data = case couch_httpd:body_length(Req) of
                     undefined ->
-                        undefined;
+                        <<"">>;
                     {unknown_transfer_encoding, Unknown} ->
                         exit({unknown_transfer_encoding, Unknown});
                     chunked ->
@@ -904,7 +904,7 @@
                                 ChunkFun, InitState)
                         end;
                     0 ->
-                        <<>>;
+                        <<"">>;
                     Length when is_integer(Length) ->
                         fun() -> couch_httpd:recv(Req, 0) end;
                     Length ->