summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/www/script/test/attachments.js12
-rw-r--r--src/couchdb/couch_httpd_db.erl4
2 files changed, 14 insertions, 2 deletions
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js
index f279c31e..1ed81ad8 100644
--- a/share/www/script/test/attachments.js
+++ b/share/www/script/test/attachments.js
@@ -225,4 +225,16 @@ couchTests.attachments= function(debug) {
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");
};
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index dab583e3..2ff02654 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -895,7 +895,7 @@ db_attachment_req(#httpd{method=Method}=Req, Db, DocId, FileNameParts)
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 @@ db_attachment_req(#httpd{method=Method}=Req, Db, DocId, FileNameParts)
ChunkFun, InitState)
end;
0 ->
- <<>>;
+ <<"">>;
Length when is_integer(Length) ->
fun() -> couch_httpd:recv(Req, 0) end;
Length ->