couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [17/50] couch commit: updated refs/heads/COUCHDB-2734-header-date to f3e022c
Date Mon, 29 Jun 2015 21:46:23 GMT
Adobe-valid MIME type for crossdomain.xml


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/eef12502
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/eef12502
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/eef12502

Branch: refs/heads/COUCHDB-2734-header-date
Commit: eef12502e56e80324149bcfc968b3ba060cf7dfe
Parents: 8c2e78e
Author: Dmitry Demeshchuk <dem@mochimedia.com>
Authored: Wed Nov 13 11:05:03 2013 -0800
Committer: Dmitry Demeshchuk <dem@mochimedia.com>
Committed: Wed Nov 13 11:05:03 2013 -0800

----------------------------------------------------------------------
 src/mochiweb_util.erl | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/eef12502/src/mochiweb_util.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_util.erl b/src/mochiweb_util.erl
index 4d39990..2690f58 100644
--- a/src/mochiweb_util.erl
+++ b/src/mochiweb_util.erl
@@ -357,11 +357,16 @@ urlsplit_query([C | Rest], Acc) ->
 %% @spec guess_mime(string()) -> string()
 %% @doc  Guess the mime type of a file by the extension of its filename.
 guess_mime(File) ->
-    case mochiweb_mime:from_extension(filename:extension(File)) of
-        undefined ->
-            "text/plain";
-        Mime ->
-            Mime
+    case filename:basename(File) of
+        "crossdomain.xml" ->
+            "text/x-cross-domain-policy";
+        _ ->
+            case mochiweb_mime:from_extension(filename:extension(File)) of
+                undefined ->
+                    "text/plain";
+                Mime ->
+                    Mime
+            end
     end.
 
 %% @spec parse_header(string()) -> {Type, [{K, V}]}
@@ -686,12 +691,14 @@ parse_header_test() ->
     ok.
 
 guess_mime_test() ->
-    "text/plain" = guess_mime(""),
-    "text/plain" = guess_mime(".text"),
-    "application/zip" = guess_mime(".zip"),
-    "application/zip" = guess_mime("x.zip"),
-    "text/html" = guess_mime("x.html"),
-    "application/xhtml+xml" = guess_mime("x.xhtml"),
+    ?assertEqual("text/plain", guess_mime("")),
+    ?assertEqual("text/plain", guess_mime(".text")),
+    ?assertEqual("application/zip", guess_mime(".zip")),
+    ?assertEqual("application/zip", guess_mime("x.zip")),
+    ?assertEqual("text/html", guess_mime("x.html")),
+    ?assertEqual("application/xhtml+xml", guess_mime("x.xhtml")),
+    ?assertEqual("text/x-cross-domain-policy", guess_mime("crossdomain.xml")),
+    ?assertEqual("text/x-cross-domain-policy", guess_mime("www/crossdomain.xml")),
     ok.
 
 path_split_test() ->


Mime
View raw message