summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-10-09 01:54:48 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-10-09 01:54:48 +0000
commite3507c9e1bb57986ccffc9324d99bec4d0e4cc58 (patch)
tree7db40aa363c912016d038532356378337f4694d6 /src
parent7a107bbe41a38f488ecfec1c01af98a415f72992 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd_external.erl22
1 files changed, 7 insertions, 15 deletions
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.