anchor.diff:      couch_httpd:send_chunk(Resp, <<"--", OuterBoundary/binary>>),
       lists:foreach(
           fun({ok, #doc{atts=Atts}=Doc}) ->
  +            Refs = monitor_attachments(Doc#doc.atts),
  +            try
               JsonBytes = ?JSON_ENCODE(couch_doc:to_json_obj(Doc, Options)),
               {ContentType, _Len} = couch_doc:len_doc_to_multi_part_stream(
                       InnerBoundary, JsonBytes, Atts, true),
  
positive.code:     case [A || A <- Atts, A#att.name == FileName] of
      [] ->
          throw({not_found, "Document is missing attachment"});
      [#att{data={Fd,_}, type=Type, encoding=Enc, disk_len=DiskLen, att_len=AttLen}=Att] ->
          Ref = monitor(process, Fd),
          try
          Etag = chttpd:doc_etag(Doc),
          ReqAcceptsAttEnc = lists:member(
  
negative.code:             {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, true)
          end
          after
              demonitor_refs(Refs)
          end;
      false ->
          send_json(Req, 200, Headers, couch_doc:to_json_obj(Doc, Options))
  