You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/02/13 17:06:19 UTC
[24/50] mochiweb commit: updated refs/heads/import-upstream to 8eb1f22
Adobe-valid MIME type for crossdomain.xml
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/eef12502
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/eef12502
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/eef12502
Branch: refs/heads/import-upstream
Commit: eef12502e56e80324149bcfc968b3ba060cf7dfe
Parents: 8c2e78e
Author: Dmitry Demeshchuk <de...@mochimedia.com>
Authored: Wed Nov 13 11:05:03 2013 -0800
Committer: Dmitry Demeshchuk <de...@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-mochiweb/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() ->