couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r823378 - /couchdb/trunk/src/couchdb/couch_httpd_external.erl
Date Fri, 09 Oct 2009 01:54:49 GMT
Author: kocolosk
Date: Fri Oct  9 01:54:48 2009
New Revision: 823378

URL: http://svn.apache.org/viewvc?rev=823378&view=rev
Log:
allow case-insensitive content-type from external, and other cleanup

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_external.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_external.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_external.erl?rev=823378&r1=823377&r2=823378&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_external.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_external.erl Fri Oct  9 01:54:48 2009
@@ -137,18 +137,10 @@
         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