summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_db.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-08-14 06:58:30 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-08-14 06:58:30 +0000
commit6b574e7ad82ab7c9d5896cac7188677f6d71e09a (patch)
treee8b11dbcb9c64d68952a2f1a53fe46b85ada0b12 /src/couchdb/couch_httpd_db.erl
parent83ec3acc48ad9918ca54168a3a41a60f6b0a615e (diff)
benoitc's attachment PUT patch passes tests for me. Closes COUCHDB-461
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@804094 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r--src/couchdb/couch_httpd_db.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 0d1e4569..084dd946 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -858,14 +858,22 @@ db_attachment_req(#httpd{method=Method}=Req, Db, DocId, FileNameParts)
CType ->
list_to_binary(CType)
end,
- data = case couch_httpd:header_value(Req,"Content-Length") of
+ data = case couch_httpd:body_length(Req) of
undefined ->
+ undefined;
+ {unknown_transfer_encoding, Unknown} ->
+ exit({unknown_transfer_encoding, Unknown});
+ chunked ->
fun(MaxChunkSize, ChunkFun, InitState) ->
couch_httpd:recv_chunked(Req, MaxChunkSize,
ChunkFun, InitState)
end;
+ 0 ->
+ <<>>;
+ Length when is_integer(Length) ->
+ fun() -> couch_httpd:recv(Req, 0) end;
Length ->
- fun() -> couch_httpd:recv(Req, 0) end
+ exit({length_not_integer, Length})
end,
len = case couch_httpd:header_value(Req,"Content-Length") of
undefined ->