You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "nickva (via GitHub)" <gi...@apache.org> on 2023/05/03 20:01:09 UTC

[GitHub] [couchdb] nickva commented on a diff in pull request #4551: test only

nickva commented on code in PR #4551:
URL: https://github.com/apache/couchdb/pull/4551#discussion_r1184198020


##########
src/chttpd/src/chttpd_db.erl:
##########
@@ -1944,26 +1944,6 @@ parse_ranges([{From, To} | Rest], Len, Acc) ->
 make_content_range(From, To, Len) ->
     ?l2b(io_lib:format("bytes ~B-~B/~B", [From, To, Len])).
 
-get_md5_header(Req) ->
-    ContentMD5 = couch_httpd:header_value(Req, "Content-MD5"),
-    Length = couch_httpd:body_length(Req),
-    Trailer = couch_httpd:header_value(Req, "Trailer"),
-    case {ContentMD5, Length, Trailer} of
-        _ when is_list(ContentMD5) orelse is_binary(ContentMD5) ->
-            base64:decode(ContentMD5);
-        {_, chunked, undefined} ->
-            <<>>;
-        {_, chunked, _} ->
-            case re:run(Trailer, "\\bContent-MD5\\b", [caseless]) of
-                {match, _} ->
-                    md5_in_footer;
-                _ ->
-                    <<>>
-            end;
-        _ ->
-            <<>>
-    end.
-

Review Comment:
   Good idea to clean up duplicate code



##########
src/chttpd/src/chttpd_db.erl:
##########
@@ -1637,15 +1637,15 @@ db_attachment_req(#httpd{method = 'GET', mochi_req = MochiReq} = Req, Db, DocId,
         atts = Atts
     } = Doc = couch_doc_open(Db, DocId, Rev, Options),
     Att = get_existing_attachment(Atts, FileName),
-    [Type, Enc, DiskLen, AttLen, Md5] = couch_att:fetch(
-        [type, encoding, disk_len, att_len, md5], Att
+    [Type, Enc, DiskLen, AttLen, Digest] = couch_att:fetch(
+        [type, encoding, disk_len, att_len, digest], Att
     ),
     Refs = monitor_attachments(Att),
     try
         Etag =
-            case Md5 of
+            case Digest of
                 <<>> -> chttpd:doc_etag(Doc);
-                _ -> "\"" ++ ?b2l(base64:encode(Md5)) ++ "\""
+                _ -> "\"" ++ ?b2l(base64:encode(Digest)) ++ "\""

Review Comment:
   Here we can probably keep the Digest variable as we're passing along whatever we got from the attachment into the ETag.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org