couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject couch-replicator commit: updated refs/heads/1637-case-sensitivity to 0785198
Date Mon, 22 Dec 2014 15:12:38 GMT
Repository: couchdb-couch-replicator
Updated Branches:
  refs/heads/1637-case-sensitivity [created] 0785198ff


Retrieve headers case-insensitively

COUCHDB-1637


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/0785198f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/0785198f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/0785198f

Branch: refs/heads/1637-case-sensitivity
Commit: 0785198ff58fa1782ff81c1db3de00c1febb97df
Parents: c9184cf
Author: Robert Newson <rnewson@apache.org>
Authored: Mon Dec 22 15:05:21 2014 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Dec 22 15:05:21 2014 +0000

----------------------------------------------------------------------
 src/couch_replicator_api_wrap.erl | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/0785198f/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_api_wrap.erl b/src/couch_replicator_api_wrap.erl
index c35659d..504a3d1 100644
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@ -230,7 +230,7 @@ open_doc_revs(#httpdb{} = HttpDb, Id, Revs, Options, Fun, Acc) ->
           (200, Headers, StreamDataFun) ->
             remote_open_doc_revs_streamer_start(Self),
             {<<"--">>, _, _} = couch_httpd:parse_multipart_request(
-                get_value("Content-Type", Headers),
+                header_value("Content-Type", Headers),
                 StreamDataFun,
                 fun mp_parse_mixed/1
             );
@@ -663,7 +663,7 @@ receive_docs(Streamer, UserFun, Ref, UserAcc) ->
     {started_open_doc_revs, NewRef} ->
         restart_remote_open_doc_revs(Ref, NewRef);
     {headers, Ref, Headers} ->
-        case get_value("content-type", Headers) of
+        case header_value("content-type", Headers) of
         {"multipart/related", _} = ContentType ->
             case couch_doc:doc_from_multi_part_stream(
                 ContentType,
@@ -936,3 +936,15 @@ stream_doc({LenLeft, Id}) when LenLeft > 0 ->
     receive {data, Ref, Data} ->
         {ok, Data, {LenLeft - iolist_size(Data), Id}}
     end.
+
+header_value(Key, Headers) ->
+    header_value(Key, Headers, undefined).
+
+header_value(Key, Headers, Default) ->
+    Headers1 = [{string:to_lower(K), V} || {K, V} <- Headers],
+    case lists:keyfind(string:to_lower(Key), 1, Headers1) of
+        {_, Value} ->
+            Value;
+        _ ->
+            Default
+    end.


Mime
View raw message