You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/10/15 18:35:43 UTC
[09/25] couch commit: updated refs/heads/master to 92598cd
Move fetching of atts from atts_to_mp into doc_to_multipart_stream
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8ef360f5
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8ef360f5
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8ef360f5
Branch: refs/heads/master
Commit: 8ef360f588cc2a23e02be27f230b6f1ad877cb89
Parents: dbf8b98
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Fri Nov 28 10:54:03 2014 -0800
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Wed May 6 06:55:58 2015 -0700
----------------------------------------------------------------------
src/couch_doc.erl | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8ef360f5/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index bcd278c..494ec53 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -408,22 +408,26 @@ len_doc_to_multi_part_stream(Boundary, JsonBytes, Atts, SendEncodedAtts) ->
doc_to_multi_part_stream(Boundary, JsonBytes, Atts, WriteFun,
SendEncodedAtts) ->
AttsToInclude = lists:filter(fun(Att)-> couch_att:fetch(data, Att) /= stub end, Atts),
- encode_multipart_stream(Boundary, JsonBytes, AttsToInclude, WriteFun, SendEncodedAtts).
+ AttsDecoded = lists:map(fun(Att) ->
+ [Name, AttLen, DiskLen, Type, Encoding] =
+ couch_att:fetch([name, att_len, disk_len, type, encoding], Att),
+ Len = case SendEncodedAtts of
+ true -> list_to_binary(integer_to_list(AttLen));
+ false -> list_to_binary(integer_to_list(DiskLen))
+ end,
+ {Att, Name, Len, Type, Encoding}
+ end, AttsToInclude),
+ encode_multipart_stream(Boundary, JsonBytes, AttsDecoded, WriteFun, SendEncodedAtts).
atts_to_mp([], _Boundary, WriteFun, _SendEncAtts) ->
WriteFun(<<"--">>);
-atts_to_mp([Att | RestAtts], Boundary, WriteFun, SendEncodedAtts) ->
+atts_to_mp([{Att, Name, LengthBin, Type, Encoding} | RestAtts], Boundary, WriteFun,
+ SendEncodedAtts) ->
case couch_att:is_stub(Att) of
true ->
unreacheable = atts_to_mp(RestAtts, Boundary, WriteFun, SendEncodedAtts);
false ->
- [Name, AttLen, DiskLen, Type, Encoding] =
- couch_att:fetch([name, att_len, disk_len, type, encoding], Att),
% write headers
- LengthBin = case SendEncodedAtts of
- true -> list_to_binary(integer_to_list(AttLen));
- false -> list_to_binary(integer_to_list(DiskLen))
- end,
WriteFun(<<"\r\nContent-Disposition: attachment; filename=\"", Name/binary, "\"">>),
WriteFun(<<"\r\nContent-Type: ", Type/binary>>),
WriteFun(<<"\r\nContent-Length: ", LengthBin/binary>>),