summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Ramage <ryan.ramage@gmail.com>2013-03-13 15:09:40 -0600
committerRyan Ramage <ryan.ramage@gmail.com>2013-03-13 15:09:40 -0600
commitbc3ef5b8cfd58b9d07868c1267c4099f994e53d8 (patch)
treeb6c573baa6af421e4440d9e8e6ffeb92c76b4f2e
parent02357223d3618467494a858ec9bae38352238261 (diff)
downloadcouchdb-1697-fix-if-non-match-cors.tar.gz
Check that the content-type from the RequestHeaders is not undefined. Fixes COUCHDB-16971697-fix-if-non-match-cors
-rw-r--r--src/couchdb/couch_httpd_cors.erl12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/couchdb/couch_httpd_cors.erl b/src/couchdb/couch_httpd_cors.erl
index 1ce890e93..ce41557ad 100644
--- a/src/couchdb/couch_httpd_cors.erl
+++ b/src/couchdb/couch_httpd_cors.erl
@@ -216,10 +216,14 @@ maybe_apply_cors_headers(CorsHeaders, RequestHeaders0) ->
% now we need to check whether the Content-Type valus is
% in ?SIMPLE_CONTENT_TYPE_VALUES and if it isn’t add Content-
% Type to to ExposedHeaders
- ContentType = string:to_lower(
- proplists:get_value("Content-Type", RequestHeaders0)),
-
- IncludeContentType = lists:member(ContentType, ?SIMPLE_CONTENT_TYPE_VALUES),
+ ContentType = proplists:get_value("Content-Type", RequestHeaders0),
+ IncludeContentType = case ContentType of
+ undefined ->
+ false;
+ _ ->
+ ContentType_ = string:to_lower(ContentType),
+ lists:member(ContentType_, ?SIMPLE_CONTENT_TYPE_VALUES)
+ end,
ExposedHeaders = case IncludeContentType of
false ->
lists:umerge(ExposedHeaders0, ["Content-Type"]);