You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2011/01/11 22:30:37 UTC
svn commit: r1057879 - in /couchdb/branches/1.1.x:
share/www/script/test/attachments_multipart.js src/couchdb/couch_httpd_db.erl
Author: fdmanana
Date: Tue Jan 11 21:30:36 2011
New Revision: 1057879
URL: http://svn.apache.org/viewvc?rev=1057879&view=rev
Log:
Merged revision 1057875 from trunk:
Make the doc multipart GET APIs always send attachments compressed
For attachments that are stored in compressed (gzip) form, make sure the
document multipart/related and multipart/mixed APIs don't decompress the
attachments before sending them through the socket. This is to avoid multipart
parser issues when the attachment's identity length is unknown or lost due to
a local to local replication triggered by CouchDB versions up to 1.0.1
Closes COUCHDB-1022.
Modified:
couchdb/branches/1.1.x/share/www/script/test/attachments_multipart.js
couchdb/branches/1.1.x/src/couchdb/couch_httpd_db.erl
Modified: couchdb/branches/1.1.x/share/www/script/test/attachments_multipart.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/share/www/script/test/attachments_multipart.js?rev=1057879&r1=1057878&r2=1057879&view=diff
==============================================================================
--- couchdb/branches/1.1.x/share/www/script/test/attachments_multipart.js (original)
+++ couchdb/branches/1.1.x/share/www/script/test/attachments_multipart.js Tue Jan 11 21:30:36 2011
@@ -29,17 +29,17 @@ couchTests.attachments_multipart= functi
"_attachments":{
"foo.txt": {
"follows":true,
- "content_type":"text/plain",
+ "content_type":"application/test",
"length":21
},
"bar.txt": {
"follows":true,
- "content_type":"text/plain",
+ "content_type":"application/test",
"length":20
},
"baz.txt": {
"follows":true,
- "content_type":"text/plain",
+ "content_type":"application/test",
"length":19
}
}
Modified: couchdb/branches/1.1.x/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_httpd_db.erl?rev=1057879&r1=1057878&r2=1057879&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_httpd_db.erl Tue Jan 11 21:30:36 2011
@@ -737,11 +737,11 @@ send_doc_efficiently(#httpd{mochi_req =
JsonBytes = ?JSON_ENCODE(couch_doc:to_json_obj(Doc,
[attachments, follows|Options])),
{ContentType, Len} = couch_doc:len_doc_to_multi_part_stream(
- Boundary,JsonBytes, Atts,false),
+ Boundary,JsonBytes, Atts, true),
CType = {<<"Content-Type">>, ContentType},
{ok, Resp} = start_response_length(Req, 200, [CType|Headers], Len),
couch_doc:doc_to_multi_part_stream(Boundary,JsonBytes,Atts,
- fun(Data) -> couch_httpd:send(Resp, Data) end, false)
+ fun(Data) -> couch_httpd:send(Resp, Data) end, true)
end;
false ->
send_json(Req, 200, Headers, couch_doc:to_json_obj(Doc, Options))
@@ -750,13 +750,7 @@ send_doc_efficiently(#httpd{mochi_req =
send_docs_multipart(Req, Results, Options1) ->
OuterBoundary = couch_uuids:random(),
InnerBoundary = couch_uuids:random(),
- {Options, CompressedAtts} =
- case couch_httpd:header_value(Req, "X-CouchDB-Send-Encoded-Atts") of
- "true" ->
- {[attachments, follows, att_encoding_info | Options1], true};
- _ ->
- {[attachments, follows | Options1], false}
- end,
+ Options = [attachments, follows, att_encoding_info | Options1],
CType = {"Content-Type",
"multipart/mixed; boundary=\"" ++ ?b2l(OuterBoundary) ++ "\""},
{ok, Resp} = start_chunked_response(Req, 200, [CType]),
@@ -765,12 +759,12 @@ send_docs_multipart(Req, Results, Option
fun({ok, #doc{atts=Atts}=Doc}) ->
JsonBytes = ?JSON_ENCODE(couch_doc:to_json_obj(Doc, Options)),
{ContentType, _Len} = couch_doc:len_doc_to_multi_part_stream(
- InnerBoundary, JsonBytes, Atts, CompressedAtts),
+ InnerBoundary, JsonBytes, Atts, true),
couch_httpd:send_chunk(Resp, <<"\r\nContent-Type: ",
ContentType/binary, "\r\n\r\n">>),
couch_doc:doc_to_multi_part_stream(InnerBoundary, JsonBytes, Atts,
fun(Data) -> couch_httpd:send_chunk(Resp, Data)
- end, CompressedAtts),
+ end, true),
couch_httpd:send_chunk(Resp, <<"\r\n--", OuterBoundary/binary>>);
({{not_found, missing}, RevId}) ->
RevStr = couch_doc:rev_to_str(RevId),