From e3507c9e1bb57986ccffc9324d99bec4d0e4cc58 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Fri, 9 Oct 2009 01:54:48 +0000 Subject: 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 --- src/couchdb/couch_httpd_external.erl | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl index ad065011..bae7a410 100644 --- a/src/couchdb/couch_httpd_external.erl +++ b/src/couchdb/couch_httpd_external.erl @@ -137,18 +137,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. -- cgit v1.2.3