couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [2/2] git commit: Get headers case-insensitively
Date Sun, 06 Jan 2013 21:33:46 GMT
Updated Branches:
  refs/heads/1637-insensitive-replicator [created] b2f7eaebb


Get headers case-insensitively


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

Branch: refs/heads/1637-insensitive-replicator
Commit: b2f7eaebbcb12f0f1953647c12964edcc5098d18
Parents: 78147f5
Author: Robert Newson <rnewson@apache.org>
Authored: Sun Jan 6 21:33:36 2013 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Sun Jan 6 21:33:36 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b2f7eaeb/src/couch_replicator/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl
index dcd6ca8..29386a6 100644
--- a/src/couch_replicator/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator/src/couch_replicator_api_wrap.erl
@@ -169,7 +169,7 @@ open_doc_revs(#httpdb{} = HttpDb, Id, Revs, Options, Fun, Acc) ->
                 fun(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)
                 end),
@@ -510,7 +510,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 doc_from_multi_part_stream(
                 ContentType,
@@ -776,3 +776,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