anchor.diff:      } = parse_doc_query(Req),
       case Revs of
       [] ->
  -        case Rev of
  -        "" -> % open most recent rev
  -            case couch_db:open_doc(Db, DocId, Options) of
  -                {ok, #doc{revs=[DocRev|_]}=Doc} ->
  -                    true;
  -                Error ->
  -                    Doc = DocRev = undefined,
  -                    throw(Error)
  -            end;
  -        _ -> % open a specific rev (deletions come back as stubs)
  -            case couch_db:open_doc_revs(Db, DocId, [Rev], Options) of
  -                {ok, [{ok, Doc}]} ->
  -                    DocRev = Rev;
  -                {ok, [Else]} ->
  -                    Doc = DocRev = undefined,
  -                    throw(Else)
  -            end
  -        end,
  +        {Doc, DocRev} = couch_doc_open(Db, DocId, Rev, Options),
           Etag = none_match(Req, DocRev),
           AdditionalHeaders = case Doc#doc.meta of
               [] -> [{"Etag", Etag}]; % output etag when we have no meta
  
positive.code:             send_error(Req, Error)
      end,
  
      ?LOG_INFO("~s - - ~p ~B", [
          Req:get(peer),
          atom_to_list(Req:get(method)) ++ " " ++ Path,
          Resp:get(code)
      ]).
  
  
negative.code:     % alias HEAD to GET as mochiweb takes care of stripping the body
      Method = case Req:get(method) of
          'HEAD' -> 'GET';
          Other -> 
            % handling of non standard HTTP verbs. Should be fixe din gen_tcp:recv()
            case Other of
              "COPY" -> 'COPY';
              "MOVE" -> 'MOVE';
              StandardMethod -> StandardMethod
            end
      end,
  
      % for the path, use the raw path with the query string and fragment
      % removed, but URL quoting left intact
      {Path, _, _} = mochiweb_util:urlsplit_path(Req:get(raw_path)),
  
      ?LOG_DEBUG("~p ~s ~p~nHeaders: ~p", [
          Method,
          Path,
          Req:get(version),
          mochiweb_headers:to_list(Req:get(headers))
  