Skip to content

Instantly share code, notes, and snippets.

@rnewson
Created December 6, 2012 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnewson/4225901 to your computer and use it in GitHub Desktop.
Save rnewson/4225901 to your computer and use it in GitHub Desktop.
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index d991de2..4f5d19d 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -458,15 +458,17 @@ len_doc_to_multi_part_stream(Boundary, JsonBytes, Atts, SendEncodedAtts) ->
_ ->
AccAttsSize +
4 + % "\r\n\r\n"
- case SendEncodedAtts of
- true ->
- % header
- length(integer_to_list(AttLen)) +
- AttLen;
- _ ->
- % header
+ case {Encoding, SendEncodedAtts} of
+ {identity, _} ->
+ % stored and served in identity form
length(integer_to_list(DiskLen)) +
- DiskLen
+ DiskLen;
+ {_, false} when DiskLen =/= AttLen->
+ length(integer_to_list(DiskLen)) +
+ DiskLen;
+ {_, true} ->
+ length(integer_to_list(AttLen)) +
+ AttLen
end +
4 + % "\r\n--"
size(Boundary) +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment