couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [14/49] chttpd commit: updated refs/heads/windsor-merge to 554ef74
Date Fri, 01 Aug 2014 09:05:50 GMT
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 <kocolosk@apache.org>
Authored: Fri Oct 9 01:54:48 2009 +0000
Committer: Robert Newson <rnewson@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.


Mime
View raw message