You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/01 11:05:50 UTC

[14/49] chttpd commit: updated refs/heads/windsor-merge to 554ef74

allow case-insensitive content-type from external, and other cleanup

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@823378 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/windsor-merge
Commit: d98c8572637f655c7c5b9c52760ba8d36fb0886c
Parents: 7bbf680
Author: Adam Kocoloski <ko...@apache.org>
Authored: Fri Oct 9 01:54:48 2009 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Jul 29 18:01:48 2014 +0100

----------------------------------------------------------------------
 src/chttpd_external.erl | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/d98c8572/src/chttpd_external.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_external.erl b/src/chttpd_external.erl
index 4d07059..e8ea919 100644
--- a/src/chttpd_external.erl
+++ b/src/chttpd_external.erl
@@ -160,18 +160,10 @@ parse_external_response({Response}) ->
         end, #extern_resp_args{}, Response).
 
 default_or_content_type(DefaultContentType, Headers) ->
-    {ContentType, OtherHeaders} = lists:partition(
-        fun({HeaderName, _}) ->
-            HeaderName == "Content-Type"
-        end, Headers),
-
-    % XXX: What happens if we were passed multiple content types? We add another?
-    case ContentType of
-        [{"Content-Type", SetContentType}] ->
-            TrueContentType = SetContentType;
-        _Else ->
-            TrueContentType = DefaultContentType
-    end,
-
-    HeadersWithContentType = lists:append(OtherHeaders, [{"Content-Type", TrueContentType}]),
-    HeadersWithContentType.
+    IsContentType = fun({X, _}) -> string:to_lower(X) == "content-type" end,
+    case lists:any(IsContentType, Headers) of
+    false ->
+        [{"Content-Type", DefaultContentType} | Headers];
+    true ->
+        Headers
+    end.