Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get headers case-insensitively

  • Loading branch information...
commit b2f7eaebbcb12f0f1953647c12964edcc5098d18 1 parent 78147f5
@rnewson rnewson authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/couch_replicator/src/couch_replicator_api_wrap.erl
View
16 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.
Please sign in to comment.
Something went wrong with that request. Please try again.