Browse files

Add access functions for #gconf{} and #sconf{} records

Applications may want to retrieve information in it. yaws:gconf_*/1 and
yaws:sconf_*/1 should be used in preference to a direct access to reduce
the dependence of your code on these records. So internal modifications
could be done avoiding the need to update and recompile your application.

Update www/internals.yaws accordingly and remove dependency on 'yaws.hrl'
in examples and applications. Add unit tests to check #gconf{} and #sconf{}
setup.
  • Loading branch information...
1 parent 7da7481 commit 48c0510bb07015a223da9899f44ddc6b26bc0abc @capflam capflam committed Nov 9, 2012
View
5 applications/wiki/src/wiki_plugin_backlinks.erl
@@ -8,15 +8,12 @@
-export([run/2]).
--include("yaws.hrl"). %% Needed only if you want to manipulate
- %% Yaws configuration
-
run(Page, ArgList) ->
%% TODO: Fixme
%% This is working if there is only one virtual server.
%% A way to handle this cleanly is needed.
{ok, Gconf, [[Sconf|Others]]} = yaws_api:getconf(),
- Root = Sconf#sconf.docroot,
+ Root = yaws:sconf_docroot(Sconf),
AllRefs = wiki_utils:getallrefs(Page, Root),
View
5 applications/wiki/src/wiki_plugin_menu.erl
@@ -11,15 +11,12 @@
-export([run/2]).
--include("yaws.hrl"). %% Needed only if you want to manipulate
- %% Yaws configuration
-
run(_Page, ArgList) ->
%% TODO: Fixme
%% This is working if there is only one virtual server.
%% A way to handle this cleanly is needed.
{ok, Gconf, [[Sconf|Others]]} = yaws_api:getconf(),
- Root = Sconf#sconf.docroot,
+ Root = yaws:sconf_docroot(Sconf),
Prefix = get_prefix(ArgList),
View
49 applications/yapp/src/yapp.erl
@@ -62,7 +62,6 @@
-author('mikael@creado.se').
-include("yaws_api.hrl").
--include("yaws.hrl").
-export([arg_rewrite/1, start/0, prepath/1, insert/1, insert/2, remove/2,
log/3,
reset_yaws_conf/0, srv_id/1,
@@ -114,8 +113,8 @@ arg_rewrite(Arg) ->
%% Add Yapp appmods, Yaws uses process dictionary.
SC = get(sc),
- AppMods = SC#sconf.appmods,
- Opaque = SC#sconf.opaque,
+ AppMods = yaws:sconf_appmods(SC),
+ Opaque = yaws:sconf_opaque(SC),
NYappPath = case YappPath of
[$/|YPTail] ->
YPTail;
@@ -127,8 +126,9 @@ arg_rewrite(Arg) ->
(AM) ->
AM
end, YappMods),
- SC2 = SC#sconf{docroot=Docroot, appmods = AppMods ++ RemappedYappMods,
- opaque = AddOpaque ++ Opaque},
+ SC2 = yaws:setup_sconf([{docroot, Docroot},
+ {appmods, AppMods ++ RemappedYappMods},
+ {opaque, AddOpaque ++ Opaque}], SC),
put(sc, SC2),
Opaque2 = Arg#arg.opaque,
@@ -246,7 +246,7 @@ insert_yapp_in_sconfgroups(SrvId, Yapp, [SCG|T]) ->
insert_yapp_in_sconfgroup(_SrvId, _Yapp, []) ->
[];
-insert_yapp_in_sconfgroup(SrvId, Yapp, [#sconf{}=SC|SCG]) ->
+insert_yapp_in_sconfgroup(SrvId, Yapp, [SC|SCG]) ->
case srv_id(SC) of
SrvId ->
case insert_yapp_in_sconf(Yapp,SC) of
@@ -286,9 +286,10 @@ start_app([AppName|T]) ->
start_app([]) -> ok;
start_app(Error) -> Error.
-insert_yapp_in_sconf0({UrlPath, AppName}, #sconf{opaque = OP} = SC) ->
+insert_yapp_in_sconf0({UrlPath, AppName}, SC) ->
log(info,"Inserting App ~p in Url ~p~n", [AppName, UrlPath]),
- AppEnv = application:get_all_env(AppName),
+ OP = yaws:sconf_opaque(SC),
+ AppEnv = application:get_all_env(AppName),
DocSubRoot = proplists:get_value(yapp_docroot, AppEnv, ?priv_docroot),
YAppMods = proplists:get_value(yapp_appmods, AppEnv, []),
YOpaque = proplists:get_value(yapp_opaque, AppEnv, []),
@@ -305,7 +306,7 @@ insert_yapp_in_sconf0({UrlPath, AppName}, #sconf{opaque = OP} = SC) ->
YR2 = insert_yapp_in_yapp_list(Y, YR),
lists:keyreplace(?yapp_list, 1, OP, {?yapp_list, YR2})
end,
- SC#sconf{opaque = OP2}.
+ yaws:setup_sconf([{opaque, OP2}], SC).
insert_yapp_in_yapp_list(#yapp{} = Y, []) ->
[Y];
@@ -336,15 +337,16 @@ remove_yapp_from_sconfgroup(SrvId, RegPath, [ H | T ]) ->
[ H | remove_yapp_from_sconfgroup(SrvId, RegPath, T ) ]
end.
-remove_yapp_from_sconf(RegPath, #sconf{opaque = OP} = SC) ->
+remove_yapp_from_sconf(RegPath, SC) ->
+ OP = yaws:sconf_opaque(SC),
OP2 = case proplists:get_value(?yapp_list, OP) of
undefined ->
OP;
YR ->
YR2 = remove_yapp_from_yapp_list(RegPath, YR),
lists:keyreplace(?yapp_list, 1, OP, {?yapp_list, YR2})
end,
- SC#sconf{opaque = OP2}.
+ yaws:setup_sconf([{opaque, OP2}], SC).
remove_yapp_from_yapp_list(_, [] ) ->
[];
@@ -371,7 +373,8 @@ get_conf() ->
%% @spec srv_id(Sconf) -> string() | undefined
%% Sconf = yawsSconf()
%% @doc Get the server id from an Sconf if available
-srv_id(#sconf{opaque = OP}) ->
+srv_id(SC) ->
+ OP = yaws:sconf_opaque(SC),
proplists:get_value(?srv_id, OP).
%% @spec get_bootstrap_yapps() -> [{ ServerId, [ {Path, ApplicationName}]}]
@@ -387,9 +390,11 @@ get_bootstrap_yapps() ->
{ok, _Gconf, Sconfs} = get_conf(),
- YL = [ {proplists:get_value(?srv_id, OP),
- make_yapp_tuples(proplists:get_value(?bootstrap_yapps, OP))}
- || #sconf{opaque=OP} <- lists:flatten(Sconfs) ],
+ YL = [begin
+ OP = yaws:sconf_opaque(SC),
+ {proplists:get_value(?srv_id, OP),
+ make_yapp_tuples(proplists:get_value(?bootstrap_yapps, OP))}
+ end || SC <- lists:flatten(Sconfs) ],
[{SrvId, Yapps} ||
{SrvId, Yapps} <- YL, SrvId =/= undefined, Yapps =/= []].
@@ -413,16 +418,20 @@ make_yapp_tuple(A) ->
%% @doc Gets all Yapps that are configured for the Yaws server.
get_yapps() ->
{ok, _Gconf, Sconfs} = yaws_api:getconf(),
- Yapps1 = [{proplists:get_value("yapp_server_id", OP),
- proplists:get_value(yapp_list, OP)} ||
- #sconf{opaque=OP} <- lists:flatten(Sconfs)],
+ Yapps1 = [begin
+ OP = yaws:sconf_opaque(SC),
+ {proplists:get_value("yapp_server_id", OP),
+ proplists:get_value(yapp_list, OP)}
+ end || SC <- lists:flatten(Sconfs)],
[{S,Y} || {S,Y} <- Yapps1, Y =/= undefined, S =/= undefined].
%% @spec get_server_ids() -> [string()]
%% @doc Lists all server ids.
get_server_ids() ->
{ok, _Gconf, Sconfs} = get_conf(),
- SrvIds1 = [proplists:get_value("yapp_server_id", OP) ||
- #sconf{opaque=OP} <- lists:flatten(Sconfs)],
+ SrvIds1 = [begin
+ OP = yaws:sconf_opaque(SC),
+ proplists:get_value("yapp_server_id", OP)
+ end || SC <- lists:flatten(Sconfs)],
[S|| S <- SrvIds1, S =/= undefined].
View
9 examples/src/authmod_gssapi.erl
@@ -84,7 +84,6 @@
out/1
]).
--include("yaws.hrl").
-include("yaws_api.hrl").
-define(SERVER, ?MODULE).
@@ -104,8 +103,8 @@
-define(ERROR, io:format).
-start(Sconf) when is_record(Sconf, sconf) ->
- Opaque = Sconf#sconf.opaque,
+start(Sconf) when is_tuple(Sconf), element(1, Sconf) == sconf ->
+ Opaque = yaws:sconf_opaque(Sconf),
start_opaque(Opaque);
@@ -120,6 +119,7 @@ start(Keytab) when is_list(Keytab) ->
supervisor:start_child(?SUPERVISOR, ChildSpec).
+
stop() ->
egssapi:stop(?SERVER),
supervisor:terminate_child(?SUPERVISOR, ?SERVER),
@@ -128,8 +128,7 @@ stop() ->
out(Arg) ->
yaws_outmod:out(Arg).
-auth(Arg, Auth) when is_record(Arg, arg),
- is_record(Auth, auth) ->
+auth(Arg, _Auth) ->
H = Arg#arg.headers,
View
9 include/yaws.hrl
@@ -99,7 +99,7 @@
ysession_mod = yaws_session_server, % storage module for ysession
acceptor_pool_size = 8, % size of acceptor proc pool
- mime_types_info
+ mime_types_info % undefined | #mime_types_info{}
}).
-record(ssl, {
@@ -211,7 +211,7 @@
yaws, % server string for this vhost
ets, % local store for this server
ssl, % undefined | #ssl{}
- authdirs = [],
+ authdirs = [], % [{docroot, [#auth{}]}]
partial_post_size = 10240,
%% An item in the appmods list can be either of the
@@ -239,8 +239,9 @@
fcgi_app_server, % FastCGI application server {host,port}
php_handler = {cgi, "/usr/bin/php-cgi"},
shaper,
- deflate_options,
- mime_types_info, % if undefined, global config is used
+ deflate_options, % undefined | #deflate{}
+ mime_types_info, % undefined | #mime_types_info{}
+ % if undefined, global config is used
dispatch_mod % custom dispatch module
}).
View
8 known_dialyzer_warnings
@@ -1,9 +1,9 @@
mime_type_c.erl:69: The variable _ can never match since previous clauses completely covered the type 'true'
-yaws.erl:2138: Guard test Ret::'file' == 'fd' can never succeed
-yaws.erl:2146: Guard test Ret::'file' == 'binfd' can never succeed
-yaws.erl:2377: The pattern 'false' can never match the type 'true'
-yaws.erl:2384: The pattern 'false' can never match the type 'true'
+yaws.erl:2383: Guard test Ret::'file' == 'fd' can never succeed
+yaws.erl:2391: Guard test Ret::'file' == 'binfd' can never succeed
+yaws.erl:2622: The pattern 'false' can never match the type 'true'
+yaws.erl:2631: The pattern 'false' can never match the type 'true'
yaws_ctl.erl:530: Function hup/1 has no local return
yaws_ctl.erl:535: Function stop/1 has no local return
yaws_ctl.erl:539: Function status/1 has no local return
View
395 src/yaws.erl
@@ -17,16 +17,70 @@
-export([start_embedded/1, start_embedded/2, start_embedded/3, start_embedded/4,
add_server/2, create_gconf/2, create_sconf/2]).
+-export([gconf_yaws_dir/1, gconf_trace/1, gconf_flags/1, gconf_logdir/1,
+ gconf_ebin_dir/1, gconf_runmods/1, gconf_keepalive_timeout/1,
+ gconf_keepalive_maxuses/1, gconf_max_num_cached_files/1,
+ gconf_max_num_cached_bytes/1, gconf_max_size_cached_file/1,
+ gconf_max_connections/1, gconf_process_options/1,
+ gconf_large_file_chunk_size/1, gconf_mnesia_dir/1,
+ gconf_log_wrap_size/1, gconf_cache_refresh_secs/1, gconf_include_dir/1,
+ gconf_phpexe/1, gconf_yaws/1, gconf_id/1, gconf_enable_soap/1,
+ gconf_soap_srv_mods/1, gconf_ysession_mod/1,
+ gconf_acceptor_pool_size/1, gconf_mime_types_info/1]).
+
+-export([sconf_port/1, sconf_flags/1, sconf_redirect_map/1, sconf_rhost/1,
+ sconf_rmethod/1, sconf_docroot/1, sconf_xtra_docroots/1,
+ sconf_listen/1, sconf_servername/1, sconf_yaws/1, sconf_ets/1,
+ sconf_ssl/1, sconf_authdirs/1, sconf_patial_post_size/1,
+ sconf_appmods/1, sconf_expires/1, sconf_errormod_401/1,
+ sconf_errormod_404/1, sconf_arg_rewrite_mode/1, sconf_logger_mod/1,
+ sconf_opaque/1, sconf_start_mod/1, sconf_allowed_scripts/1,
+ sconf_tilde_allowed_scripts/1, sconf_index_files/1, sconf_revproxy/1,
+ sconf_spotions/1, sconf_extra_cgi_vars/1, sconf_stats/1,
+ sconf_fcgi_app_server/1, sconf_php_handler/1, sconf_shaper/1,
+ sconf_deflate_options/1, sconf_mime_types_info/1,
+ sconf_dispatch_mod/1]).
+
+-export([new_auth/0,
+ auth_dir/1, auth_dir/2,
+ auth_docroot/1, auth_docroot/2,
+ auth_files/1, auth_files/2,
+ auth_realm/1, auth_realm/2,
+ auth_type/1, auth_type/2,
+ auth_headers/1, auth_headers/2,
+ auth_users/1, auth_users/2,
+ auth_acl/1, auth_acl/2,
+ auth_mod/1, auth_mod/2,
+ auth_outmod/1, auth_outmod/2,
+ auth_pam/1, auth_pam/2]).
+
-export([new_ssl/0,
ssl_keyfile/1, ssl_keyfile/2,
ssl_certfile/1, ssl_certfile/2,
ssl_verify/1, ssl_verify/2,
+ ssl_fail_if_no_peer_cert/1, ssl_fail_if_no_peer_cert/2,
ssl_depth/1, ssl_depth/2,
ssl_password/1, ssl_password/2,
ssl_cacertfile/1, ssl_cacertfile/2,
ssl_ciphers/1, ssl_ciphers/2,
ssl_cachetimeout/1, ssl_cachetimeout/2]).
+-export([new_deflate/0,
+ deflate_min_compress_size/1, deflate_min_compress_size/2,
+ deflate_compression_level/1, deflate_compression_level/2,
+ deflate_window_size/1, deflate_window_size/2,
+ deflate_mem_level/1, deflate_mem_level/2,
+ deflate_strategy/1, deflate_strategy/2,
+ deflate_use_gzip_static/1, deflate_use_gzip_static/2,
+ deflate_mime_types/1, deflate_mime_types/2]).
+
+-export([new_mime_types_info/0,
+ mime_types_info_mime_types_file/1, mime_types_info_mime_types_file/2,
+ mime_types_info_types/1, mime_types_info_types/2,
+ mime_types_info_charsets/1, mime_types_info_charsets/2,
+ mime_types_info_default_type/1, mime_types_info_default_type/2,
+ mime_types_info_default_charset/1, mime_types_info_default_charset/2]).
+
-export([first/2, elog/2, filesize/1, upto/2, to_string/1, to_list/1,
integer_to_hex/1, hex_to_integer/1, string_to_hex/1, hex_to_string/1,
is_modified_p/2, flag/3, dohup/1, is_ssl/1, address/0, is_space/1,
@@ -155,26 +209,259 @@ create_sconf(DocRoot, SL) when is_list(DocRoot), is_list(SL) ->
setup_sconf(SL, SC).
-%%% Access functions for the SSL record.
+
+%% Access functions for the GCONF and SCONF records.
+gconf_yaws_dir (#gconf{yaws_dir = X}) -> X.
+gconf_trace (#gconf{trace = X}) -> X.
+gconf_flags (#gconf{flags = X}) -> X.
+gconf_logdir (#gconf{logdir = X}) -> X.
+gconf_ebin_dir (#gconf{ebin_dir = X}) -> X.
+gconf_runmods (#gconf{runmods = X}) -> X.
+gconf_keepalive_timeout (#gconf{keepalive_timeout = X}) -> X.
+gconf_keepalive_maxuses (#gconf{keepalive_maxuses = X}) -> X.
+gconf_max_num_cached_files (#gconf{max_num_cached_files = X}) -> X.
+gconf_max_num_cached_bytes (#gconf{max_num_cached_bytes = X}) -> X.
+gconf_max_size_cached_file (#gconf{max_size_cached_file = X}) -> X.
+gconf_max_connections (#gconf{max_connections = X}) -> X.
+gconf_process_options (#gconf{process_options = X}) -> X.
+gconf_large_file_chunk_size(#gconf{large_file_chunk_size = X}) -> X.
+gconf_mnesia_dir (#gconf{mnesia_dir = X}) -> X.
+gconf_log_wrap_size (#gconf{log_wrap_size = X}) -> X.
+gconf_cache_refresh_secs (#gconf{cache_refresh_secs = X}) -> X.
+gconf_include_dir (#gconf{include_dir = X}) -> X.
+gconf_phpexe (#gconf{phpexe = X}) -> X.
+gconf_yaws (#gconf{yaws = X}) -> X.
+gconf_id (#gconf{id = X}) -> X.
+gconf_enable_soap (#gconf{enable_soap = X}) -> X.
+gconf_soap_srv_mods (#gconf{soap_srv_mods = X}) -> X.
+gconf_ysession_mod (#gconf{ysession_mod = X}) -> X.
+gconf_acceptor_pool_size (#gconf{acceptor_pool_size = X}) -> X.
+gconf_mime_types_info (#gconf{mime_types_info = X}) -> X.
+
+
+sconf_port (#sconf{port = X}) -> X.
+sconf_flags (#sconf{flags = X}) -> X.
+sconf_redirect_map (#sconf{redirect_map = X}) -> X.
+sconf_rhost (#sconf{rhost = X}) -> X.
+sconf_rmethod (#sconf{rmethod = X}) -> X.
+sconf_docroot (#sconf{docroot = X}) -> X.
+sconf_xtra_docroots (#sconf{xtra_docroots = X}) -> X.
+sconf_listen (#sconf{listen = X}) -> X.
+sconf_servername (#sconf{servername = X}) -> X.
+sconf_yaws (#sconf{yaws = X}) -> X.
+sconf_ets (#sconf{ets = X}) -> X.
+sconf_ssl (#sconf{ssl = X}) -> X.
+sconf_authdirs (#sconf{authdirs = X}) -> X.
+sconf_patial_post_size (#sconf{partial_post_size = X}) -> X.
+sconf_appmods (#sconf{appmods = X}) -> X.
+sconf_expires (#sconf{expires = X}) -> X.
+sconf_errormod_401 (#sconf{errormod_401 = X}) -> X.
+sconf_errormod_404 (#sconf{errormod_404 = X}) -> X.
+sconf_arg_rewrite_mode (#sconf{arg_rewrite_mod = X}) -> X.
+sconf_logger_mod (#sconf{logger_mod = X}) -> X.
+sconf_opaque (#sconf{opaque = X}) -> X.
+sconf_start_mod (#sconf{start_mod = X}) -> X.
+sconf_allowed_scripts (#sconf{allowed_scripts = X}) -> X.
+sconf_tilde_allowed_scripts(#sconf{tilde_allowed_scripts = X}) -> X.
+sconf_index_files (#sconf{index_files = X}) -> X.
+sconf_revproxy (#sconf{revproxy = X}) -> X.
+sconf_spotions (#sconf{soptions = X}) -> X.
+sconf_extra_cgi_vars (#sconf{extra_cgi_vars = X}) -> X.
+sconf_stats (#sconf{stats = X}) -> X.
+sconf_fcgi_app_server (#sconf{fcgi_app_server = X}) -> X.
+sconf_php_handler (#sconf{php_handler = X}) -> X.
+sconf_shaper (#sconf{shaper = X}) -> X.
+sconf_deflate_options (#sconf{deflate_options = X}) -> X.
+sconf_mime_types_info (#sconf{mime_types_info = X}) -> X.
+sconf_dispatch_mod (#sconf{dispatch_mod = X}) -> X.
+
+
+%% Access functions for the AUTH record.
+new_auth() -> #auth{}.
+
+auth_dir (#auth{dir = X}) -> X.
+auth_docroot(#auth{docroot = X}) -> X.
+auth_files (#auth{files = X}) -> X.
+auth_realm (#auth{realm = X}) -> X.
+auth_type (#auth{type = X}) -> X.
+auth_headers(#auth{headers = X}) -> X.
+auth_users (#auth{users = X}) -> X.
+auth_acl (#auth{acl = X}) -> X.
+auth_mod (#auth{mod = X}) -> X.
+auth_outmod (#auth{outmod = X}) -> X.
+auth_pam (#auth{pam = X}) -> X.
+
+auth_dir (A, Dir) -> A#auth{dir = Dir}.
+auth_docroot(A, DocRoot) -> A#auth{docroot = DocRoot}.
+auth_files (A, Files) -> A#auth{files = Files}.
+auth_realm (A, Realm) -> A#auth{realm = Realm}.
+auth_type (A, Type) -> A#auth{type = Type}.
+auth_headers(A, Headers) -> A#auth{headers = Headers}.
+auth_users (A, Users) -> A#auth{users = Users}.
+auth_acl (A, Acl) -> A#auth{acl = Acl}.
+auth_mod (A, Mod) -> A#auth{mod = Mod}.
+auth_outmod (A, Outmod) -> A#auth{outmod = Outmod}.
+auth_pam (A, Pam) -> A#auth{pam = Pam}.
+
+
+setup_authdirs(SL, DefaultAuthDirs) ->
+ case [A || {auth, A} <- SL] of
+ [] -> DefaultAuthDirs;
+ As -> [setup_auth(A) || A <- As]
+ end.
+
+setup_auth(#auth{}=Auth) ->
+ Auth;
+setup_auth(AuthProps) ->
+ Auth = #auth{},
+ #auth{dir = lkup(dir, AuthProps, Auth#auth.dir),
+ docroot = lkup(docroot, AuthProps, Auth#auth.docroot),
+ files = lkup(files, AuthProps, Auth#auth.files),
+ realm = lkup(realm, AuthProps, Auth#auth.realm),
+ type = lkup(type, AuthProps, Auth#auth.type),
+ headers = lkup(headers, AuthProps, Auth#auth.headers),
+ users = lkup(users, AuthProps, Auth#auth.users),
+ acl = lkup(acl, AuthProps, Auth#auth.acl),
+ mod = lkup(mod, AuthProps, Auth#auth.mod),
+ outmod = lkup(outmod, AuthProps, Auth#auth.outmod),
+ pam = lkup(pam, AuthProps, Auth#auth.pam)}.
+
+
+%% Access functions for the SSL record.
new_ssl() -> #ssl{}.
-ssl_keyfile(S) -> S#ssl.keyfile.
-ssl_certfile(S) -> S#ssl.certfile.
-ssl_verify(S) -> S#ssl.verify.
-ssl_depth(S) -> S#ssl.depth.
-ssl_password(S) -> S#ssl.password.
-ssl_cacertfile(S) -> S#ssl.cacertfile.
-ssl_ciphers(S) -> S#ssl.ciphers.
-ssl_cachetimeout(S) -> S#ssl.cachetimeout.
-
-ssl_keyfile(S, Keyfile) -> S#ssl{keyfile = Keyfile}.
-ssl_certfile(S, Certfile) -> S#ssl{certfile = Certfile}.
-ssl_verify(S, Verify) -> S#ssl{verify = Verify}.
-ssl_depth(S, Depth) -> S#ssl{depth = Depth}.
-ssl_password(S, Password) -> S#ssl{password = Password}.
-ssl_cacertfile(S, Cacertfile) -> S#ssl{cacertfile = Cacertfile}.
-ssl_ciphers(S, Ciphers) -> S#ssl{ciphers = Ciphers}.
-ssl_cachetimeout(S, Cachetimeout) -> S#ssl{cachetimeout = Cachetimeout}.
+ssl_keyfile (#ssl{keyfile = X}) -> X.
+ssl_certfile (#ssl{certfile = X}) -> X.
+ssl_verify (#ssl{verify = X}) -> X.
+ssl_fail_if_no_peer_cert(#ssl{fail_if_no_peer_cert = X}) -> X.
+ssl_depth (#ssl{depth = X}) -> X.
+ssl_password (#ssl{password = X}) -> X.
+ssl_cacertfile (#ssl{cacertfile = X}) -> X.
+ssl_ciphers (#ssl{ciphers = X}) -> X.
+ssl_cachetimeout (#ssl{cachetimeout = X}) -> X.
+
+ssl_keyfile (S, File) -> S#ssl{keyfile = File}.
+ssl_certfile (S, File) -> S#ssl{certfile = File}.
+ssl_verify (S, Verify) -> S#ssl{verify = Verify}.
+ssl_fail_if_no_peer_cert(S, Bool) -> S#ssl{fail_if_no_peer_cert = Bool}.
+ssl_depth (S, Depth) -> S#ssl{depth = Depth}.
+ssl_password (S, Pass) -> S#ssl{password = Pass}.
+ssl_cacertfile (S, File) -> S#ssl{cacertfile = File}.
+ssl_ciphers (S, Ciphers) -> S#ssl{ciphers = Ciphers}.
+ssl_cachetimeout (S, Timeout) -> S#ssl{cachetimeout = Timeout}.
+
+
+setup_ssl(SL, DefaultSSL) ->
+ case lkup(ssl, SL, undefined) of
+ undefined ->
+ DefaultSSL;
+ SSL when is_record(SSL, ssl) ->
+ SSL;
+ SSLProps when is_list(SSLProps) ->
+ SSL = #ssl{},
+ #ssl{keyfile = lkup(keyfile, SSLProps,
+ SSL#ssl.keyfile),
+ certfile = lkup(certfile, SSLProps,
+ SSL#ssl.certfile),
+ verify = lkup(verify, SSLProps, SSL#ssl.verify),
+ fail_if_no_peer_cert = lkup(fail_if_no_peer_cert, SSLProps,
+ SSL#ssl.fail_if_no_peer_cert),
+ depth = lkup(depth, SSLProps, SSL#ssl.depth),
+ password = lkup(password, SSLProps,
+ SSL#ssl.password),
+ cacertfile = lkup(cacertfile, SSLProps,
+ SSL#ssl.cacertfile),
+ ciphers = lkup(ciphers, SSLProps,
+ SSL#ssl.ciphers),
+ cachetimeout = lkup(cachetimeout, SSLProps,
+ SSL#ssl.cachetimeout)}
+ end.
+
+
+%% Access functions for the DEFLATE record.
+new_deflate() -> #deflate{}.
+
+deflate_min_compress_size(#deflate{min_compress_size = X}) -> X.
+deflate_compression_level(#deflate{compression_level = X}) -> X.
+deflate_window_size (#deflate{window_size = X}) -> X.
+deflate_mem_level (#deflate{mem_level = X}) -> X.
+deflate_strategy (#deflate{strategy = X}) -> X.
+deflate_use_gzip_static (#deflate{use_gzip_static = X}) -> X.
+deflate_mime_types (#deflate{mime_types = X}) -> X.
+
+deflate_min_compress_size(D, Min) -> D#deflate{min_compress_size = Min}.
+deflate_compression_level(D, Level) -> D#deflate{compression_level = Level}.
+deflate_window_size (D, Size) -> D#deflate{window_size = Size}.
+deflate_mem_level (D, Level) -> D#deflate{mem_level = Level}.
+deflate_strategy (D, Strat) -> D#deflate{strategy = Strat}.
+deflate_use_gzip_static (D, Bool) -> D#deflate{use_gzip_static = Bool}.
+deflate_mime_types (D, Types) -> D#deflate{mime_types = Types}.
+
+
+setup_deflate(SL, DefaultDeflate) ->
+ case lkup(deflate_options, SL, undefined) of
+ undefined ->
+ DefaultDeflate;
+ D when is_record(D, deflate) ->
+ D;
+ DProps when is_list(DProps) ->
+ D = #deflate{},
+ #deflate{min_compress_size = lkup(min_compress_size, DProps,
+ D#deflate.min_compress_size),
+ compression_level = lkup(compression_level, DProps,
+ D#deflate.compression_level),
+ window_size = lkup(window_size, DProps,
+ D#deflate.window_size),
+ mem_level = lkup(mem_level, DProps,
+ D#deflate.mem_level),
+ strategy = lkup(strategy, DProps,
+ D#deflate.strategy),
+ use_gzip_static = lkup(use_gzip_static, DProps,
+ D#deflate.use_gzip_static),
+ mime_types = lkup(mime_types, DProps,
+ D#deflate.mime_types)}
+ end.
+
+%% Access functions to MIME_TYPES_INFO record.
+new_mime_types_info() -> #mime_types_info{}.
+
+mime_types_info_mime_types_file(#mime_types_info{mime_types_file = X}) -> X.
+mime_types_info_types (#mime_types_info{types = X}) -> X.
+mime_types_info_charsets (#mime_types_info{charsets = X}) -> X.
+mime_types_info_default_type (#mime_types_info{default_type = X}) -> X.
+mime_types_info_default_charset(#mime_types_info{default_charset = X}) -> X.
+
+mime_types_info_mime_types_file(M, File) ->
+ M#mime_types_info{mime_types_file = File}.
+mime_types_info_types(M, Types) ->
+ M#mime_types_info{types = Types}.
+mime_types_info_charsets(M, Charsets) ->
+ M#mime_types_info{charsets = Charsets}.
+mime_types_info_default_type(M, Type) ->
+ M#mime_types_info{default_type = Type}.
+mime_types_info_default_charset(M, Charset) ->
+ M#mime_types_info{default_charset = Charset}.
+
+
+setup_mime_types_info(SL, DefaultMTI) ->
+ case lkup(mime_types_info, SL, undefined) of
+ undefined ->
+ DefaultMTI;
+ M when is_record(M, mime_types_info) ->
+ M;
+ MProps when is_list(MProps) ->
+ M = #mime_types_info{},
+ #mime_types_info{mime_types_file = lkup(mime_types_file, MProps,
+ M#mime_types_info.mime_types_file),
+ types = lkup(types, MProps,
+ M#mime_types_info.types),
+ charsets = lkup(charsets, MProps,
+ M#mime_types_info.charsets),
+ default_type = lkup(default_type, MProps,
+ M#mime_types_info.default_type),
+ default_charset = lkup(default_charset, MProps,
+ M#mime_types_info.default_charset)}
+ end.
%% Setup global configuration
@@ -219,8 +506,9 @@ setup_gconf(GL, GC) ->
GC#gconf.ysession_mod),
acceptor_pool_size = lkup(acceptor_pool_size, GL,
GC#gconf.acceptor_pool_size),
- mime_types_info = lkup(mime_types_info, GL,
- GC#gconf.mime_types_info)
+ mime_types_info = setup_mime_types_info(
+ GL, GC#gconf.mime_types_info
+ )
}.
set_gc_flags([{tty_trace, Bool}|T], Flags) ->
@@ -262,9 +550,8 @@ setup_sconf(SL, SC) ->
servername = lkup(servername, SL, SC#sconf.servername),
yaws = lkup(yaws, SL, SC#sconf.yaws),
ets = lkup(ets, SL, SC#sconf.ets),
- ssl = setup_sconf_ssl(SL, SC#sconf.ssl),
- authdirs = lkup(authdirs, expand_auth(SL),
- SC#sconf.authdirs),
+ ssl = setup_ssl(SL, SC#sconf.ssl),
+ authdirs = setup_authdirs(SL, SC#sconf.authdirs),
partial_post_size = lkup(partial_post_size, SL,
SC#sconf.partial_post_size),
appmods = lkup(appmods, SL, SC#sconf.appmods),
@@ -292,55 +579,13 @@ setup_sconf(SL, SC) ->
SC#sconf.fcgi_app_server),
php_handler = lkup(php_handler, SL, SC#sconf.php_handler),
shaper = lkup(shaper, SL, SC#sconf.shaper),
- deflate_options = lkup(deflate_options, SL,
- SC#sconf.deflate_options),
- mime_types_info = lkup(mime_types_info, SL,
- SC#sconf.mime_types_info),
- dispatch_mod = lkup(dispatchmod, SL,
- SC#sconf.dispatch_mod)
+ deflate_options = setup_deflate(SL, SC#sconf.deflate_options),
+ mime_types_info = setup_mime_types_info(
+ SL, SC#sconf.mime_types_info
+ ),
+ dispatch_mod = lkup(dispatchmod, SL, SC#sconf.dispatch_mod)
}.
-expand_auth(SL) ->
- case [A || {auth, A} <- SL] of
- [] -> SL;
- As -> [{authdirs, [opts_to_auth(O) || O <- As]}|SL]
- end.
-
-opts_to_auth(Opts) ->
- {_, Auth} =
- lists:foldl(fun(F, {P,A}) ->
- Val = proplists:get_value(F, Opts, element(P,A)),
- {P+1, setelement(P, A, Val)}
- end, {2, #auth{}}, record_info(fields, auth)),
- Auth.
-
-setup_sconf_ssl(SL, DefaultSSL) ->
- case lkup(ssl, SL, undefined) of
- undefined ->
- DefaultSSL;
- SSL when is_record(SSL, ssl) ->
- SSL;
- SSLProps when is_list(SSLProps) ->
- SSL1 = #ssl{
- keyfile = proplists:get_value(keyfile, SSLProps),
- certfile = proplists:get_value(certfile, SSLProps),
- password = proplists:get_value(password, SSLProps),
- cacertfile = proplists:get_value(cacertfile, SSLProps),
- ciphers = proplists:get_value(ciphers, SSLProps),
- cachetimeout = proplists:get_value(cachetimeout, SSLProps)
- },
- %% Prevent overriding the ssl record's default values!
- SSL2 =
- case proplists:get_value(verify, SSLProps) of
- undefined -> SSL1;
- Verify -> SSL1#ssl{verify=Verify}
- end,
- case proplists:get_value(depth, SSLProps) of
- undefined -> SSL2;
- Depth -> SSL2#ssl{depth=Depth}
- end
- end.
-
set_sc_flags([{access_log, Bool}|T], Flags) ->
set_sc_flags(T, flag(Flags, ?SC_ACCESS_LOG, Bool));
set_sc_flags([{auth_log, Bool}|T], Flags) ->
@@ -361,18 +606,22 @@ set_sc_flags([{dav, Bool}|T], Flags) ->
set_sc_flags(T, flag(Flags, ?SC_DAV, Bool));
set_sc_flags([{fcgi_trace_protocol, Bool}|T], Flags) ->
set_sc_flags(T, flag(Flags, ?SC_FCGI_TRACE_PROTOCOL, Bool));
+set_sc_flags([{fcgi_log_app_error, Bool}|T], Flags) ->
+ set_sc_flags(T, flag(Flags, ?SC_FCGI_LOG_APP_ERROR, Bool));
set_sc_flags([{forward_proxy, Bool}|T], Flags) ->
set_sc_flags(T, flag(Flags, ?SC_FORWARD_PROXY, Bool));
+set_sc_flags([{auth_skip_docroot, Bool}|T], Flags) ->
+ set_sc_flags(T, flag(Flags, ?SC_AUTH_SKIP_DOCROOT, Bool));
set_sc_flags([_Unknown|T], Flags) ->
error_logger:format("Unknown and unhandled flag ~p~n", [_Unknown]),
set_sc_flags(T, Flags);
set_sc_flags([], Flags) ->
Flags.
lkup(Key, List, Def) ->
- case lists:keysearch(Key, 1, List) of
- {value,{_,Value}} -> Value;
- _ -> Def
+ case lists:keyfind(Key, 1, List) of
+ {_,Value} -> Value;
+ _ -> Def
end.
View
4 test/eunit/Makefile
@@ -5,7 +5,9 @@ OBJ := multipart_post_parsing.beam \
ehtml_test.beam \
cookies.beam \
headers.beam \
- ipmask.beam
+ ipmask.beam \
+ gconf.beam \
+ sconf.beam
all: $(OBJ)
View
87 test/eunit/gconf.erl
@@ -0,0 +1,87 @@
+-module(gconf).
+-compile(export_all).
+-include("../../include/yaws.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+
+setup_default_gconf_test() ->
+ Dir = yaws_dir(),
+ EbinDir = Dir++"/examples/ebin",
+ IncDir = Dir++"/examples/include",
+
+ GC = yaws_config:make_default_gconf(false, "test"),
+ GC = yaws:create_gconf([], "test"),
+
+ {yaws_dir, Dir} = get_gconf_attr(yaws_dir, GC),
+ {ebin_dir, [EbinDir]} = get_gconf_attr(ebin_dir, GC),
+ {include_dir, [IncDir]} = get_gconf_attr(include_dir, GC),
+ {trace, false} = get_gconf_attr(trace, GC),
+ {flags, 100} = get_gconf_attr(flags, GC),
+ {id, "test"} = get_gconf_attr(id, GC),
+
+ ok.
+
+set_gc_flags_test() ->
+ GC = yaws:create_gconf([], "test"),
+ {tty_trace, true} =
+ check_gc_flags(tty_trace, ?GC_TTY_TRACE, GC),
+ {debug, true} =
+ check_gc_flags(debug, ?GC_DEBUG, GC),
+ {copy_errlog, true} =
+ check_gc_flags(copy_errlog, ?GC_COPY_ERRLOG, GC),
+ {backwards_compat_parse, true} =
+ check_gc_flags(backwards_compat_parse, ?GC_BACKWARDS_COMPAT_PARSE, GC),
+ {fail_on_bind_err, true} =
+ check_gc_flags(fail_on_bind_err, ?GC_FAIL_ON_BIND_ERR, GC),
+ {log_resolve_hostname, true} =
+ check_gc_flags(log_resolve_hostname, ?GC_LOG_RESOLVE_HOSTNAME, GC),
+ {pick_first_virthost_on_nomatch, true} =
+ check_gc_flags(pick_first_virthost_on_nomatch,
+ ?GC_PICK_FIRST_VIRTHOST_ON_NOMATCH, GC),
+ {use_old_ssl, true} =
+ check_gc_flags(use_old_ssl, ?GC_USE_OLD_SSL, GC),
+ ok.
+
+
+setup_mime_types_info_test() ->
+ GC0 = yaws:create_gconf([], "test"),
+ undefined = yaws:gconf_mime_types_info(GC0),
+
+ GC1 = yaws:create_gconf([{mime_types_info, []}], "test"),
+ MI1 = yaws:new_mime_types_info(),
+ MI1 = yaws:gconf_mime_types_info(GC1),
+
+ MI2 = yaws:mime_types_info_mime_types_file(MI1, "/etc/mime.types"),
+ GC2 = yaws:create_gconf([{mime_types_info, MI2}], "test"),
+ "/etc/mime.types" = yaws:mime_types_info_mime_types_file
+ (yaws:gconf_mime_types_info(GC2)
+ ),
+ ok.
+
+
+%% =======================================================================
+get_gconf_attr(Name, GConf) ->
+ Fun = list_to_atom("gconf_" ++ atom_to_list(Name)),
+ {Name, yaws:Fun(GConf)}.
+
+
+check_gc_flags(Flag, Id, GConf0) ->
+ Flags0 = yaws:gconf_flags(GConf0),
+ Val0 = (Flags0 band Id) /= 0,
+
+ GConf1 = yaws:create_gconf([{flags, [{Flag, not Val0}]}], "test"),
+ Flags1 = yaws:gconf_flags(GConf1),
+ Flags2 = yaws:flag(Flags1, Id, Val0),
+
+ {Flag,
+ (not Val0 == ((Flags1 band Id) /= 0) andalso Flags2 == Flags0)}.
+
+
+yaws_dir() ->
+ filename:dirname( %% yaws_dir/
+ filename:dirname( %% yaws_dir/test/
+ filename:dirname( %% yaws_dir/test/eunit
+ filename:absname(code:which(?MODULE))
+ )
+ )
+ ).
View
135 test/eunit/sconf.erl
@@ -0,0 +1,135 @@
+-module(sconf).
+-compile(export_all).
+-include("../../include/yaws.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+
+setup_default_sconf_test() ->
+ Dir = filename:absname("."),
+
+ SC1 = yaws_config:make_default_sconf(".", undefined),
+ SC1 = yaws:create_sconf(".", []),
+ {docroot, Dir} = get_sconf_attr(docroot, SC1),
+ {listen, {127,0,0,1}} = get_sconf_attr(listen, SC1),
+ {port, 8000} = get_sconf_attr(port, SC1),
+
+
+ SC2 = yaws_config:make_default_sconf(".", 8080),
+ SC2 = yaws:create_sconf(".", [{port, 8080}]),
+ {port, 8080} = get_sconf_attr(port, SC2),
+
+ ok.
+
+
+set_sc_flags_test() ->
+ SC = yaws:create_sconf(".", []),
+ {access_log, true} =
+ check_sc_flags(access_log, ?SC_ACCESS_LOG, SC),
+ {auth_log, true} =
+ check_sc_flags(auth_log, ?SC_AUTH_LOG, SC),
+ {add_port, true} =
+ check_sc_flags(add_port, ?SC_ADD_PORT, SC),
+ {statistics, true} =
+ check_sc_flags(statistics, ?SC_STATISTICS, SC),
+ {tilde_expand, true} =
+ check_sc_flags(tilde_expand, ?SC_TILDE_EXPAND, SC),
+ {dir_listings, true} =
+ check_sc_flags(dir_listings, ?SC_DIR_LISTINGS, SC),
+ {deflate, true} =
+ check_sc_flags(deflate, ?SC_DEFLATE, SC),
+ {dir_all_zip, true} =
+ check_sc_flags(dir_all_zip, ?SC_DIR_ALL_ZIP, SC),
+ {dav, true} =
+ check_sc_flags(dav, ?SC_DAV, SC),
+ {fcgi_trace_protocol, true} =
+ check_sc_flags(fcgi_trace_protocol, ?SC_FCGI_TRACE_PROTOCOL, SC),
+ {fcgi_log_app_error, true} =
+ check_sc_flags(fcgi_log_app_error, ?SC_FCGI_LOG_APP_ERROR, SC),
+ {forward_proxy, true} =
+ check_sc_flags(forward_proxy, ?SC_FORWARD_PROXY, SC),
+ {auth_skip_docroot, true} =
+ check_sc_flags(auth_skip_docroot, ?SC_AUTH_SKIP_DOCROOT, SC),
+ ok.
+
+
+setup_ssl_test() ->
+ SC0 = yaws:create_sconf(".", []),
+ undefined = yaws:sconf_ssl(SC0),
+
+ SC1 = yaws:create_sconf(".", [{ssl, []}]),
+ SSL1 = yaws:new_ssl(),
+ SSL1 = yaws:sconf_ssl(SC1),
+
+ SSL2 = yaws:ssl_keyfile(SSL1, "/tmp/yaws-key.pem"),
+ SC2 = yaws:create_sconf(".", [{ssl, SSL2}]),
+ "/tmp/yaws-key.pem" = yaws:ssl_keyfile(
+ yaws:sconf_ssl(SC2)
+ ),
+ ok.
+
+
+setup_authdirs_test() ->
+ SC0 = yaws:create_sconf(".", []),
+ [] = yaws:sconf_authdirs(SC0),
+
+ SC1 = yaws:create_sconf(".", [{auth, []}]),
+ Auth1 = yaws:new_auth(),
+ [Auth1] = yaws:sconf_authdirs(SC1),
+
+ Auth2 = yaws:auth_dir(Auth1, "/"),
+ SC2 = yaws:create_sconf(".", [{auth, Auth2}]),
+ "/" = yaws:auth_dir(
+ hd(yaws:sconf_authdirs(SC2))
+ ),
+ ok.
+
+
+setup_deflate_test() ->
+ SC0 = yaws:create_sconf(".", []),
+ undefined = yaws:sconf_deflate_options(SC0),
+
+ SC1 = yaws:create_sconf(".", [{deflate_options, []}]),
+ DOpts1 = yaws:new_deflate(),
+ DOpts1 = yaws:sconf_deflate_options(SC1),
+
+ DOpts2 = yaws:deflate_compression_level(DOpts1, best_speed),
+ SC2 = yaws:create_sconf(".", [{deflate_options, DOpts2}]),
+ best_speed = yaws:deflate_compression_level(
+ yaws:sconf_deflate_options(SC2)
+ ),
+ ok.
+
+
+setup_mime_types_info_test() ->
+ SC0 = yaws:create_sconf(".", []),
+ undefined = yaws:sconf_mime_types_info(SC0),
+
+ SC1 = yaws:create_sconf(".", [{mime_types_info, []}]),
+ MI1 = yaws:new_mime_types_info(),
+ MI1 = yaws:sconf_mime_types_info(SC1),
+
+ MI2 = yaws:mime_types_info_mime_types_file(MI1, "/etc/mime.types"),
+ SC2 = yaws:create_sconf(".", [{mime_types_info, MI2}]),
+ "/etc/mime.types" = yaws:mime_types_info_mime_types_file(
+ yaws:sconf_mime_types_info(SC2)
+ ),
+ ok.
+
+
+
+%% =======================================================================
+get_sconf_attr(Name, SConf) ->
+ Fun = list_to_atom("sconf_" ++ atom_to_list(Name)),
+ {Name, yaws:Fun(SConf)}.
+
+
+check_sc_flags(Flag, Id, SConf0) ->
+ Flags0 = yaws:sconf_flags(SConf0),
+ Val0 = (Flags0 band Id) /= 0,
+
+ SConf1 = yaws:create_sconf(".", [{flags, [{Flag, not Val0}]}]),
+ Flags1 = yaws:sconf_flags(SConf1),
+ Flags2 = yaws:flag(Flags1, Id, Val0),
+
+ {Flag,
+ (not Val0 == ((Flags1 band Id) /= 0) andalso Flags2 == Flags0)}.
View
134 www/internals.yaws
@@ -141,6 +141,11 @@ out(A) ->
the two most important datastructures in Yaws. The <tt>#gconf{}</tt>
and the <tt>#sconf{}</tt> records.
</p>
+ <p><b>Note:</b> To retrieve information from these records, yaws:gconf_*/1
+ and yaws:sconf_*/1 (e.g. yaws:gconf_id/1 or yaws:sconf_docroot/1) should
+ be used in preference to a direct access to reduce the dependence of your
+ code on it.
+ </p>
<h3>The <tt>#gconf{}</tt> record</h3>
<p>This record is used to hold all global state, i.e. state and configuration
@@ -152,26 +157,46 @@ out(A) ->
%%global conf
record(gconf,{
- yaws_dir, %% topdir of Yaws installation
- trace, %% false | {true,http}|{true,traffic}
- flags = ?GC_DEF, %% boolean flags
- logdir,
- ebin_dir = [],
- runmods = [], %% runmods for entire server
- keepalive_timeout = 15000,
- max_num_cached_files = 400,
- max_num_cached_bytes = 1000000, %% 1 MEG
- max_size_cached_file = 8000,
- large_file_chunk_size = 10240,
- mnesia_dir = [],
- log_wrap_size = 1000000, % wrap logs after 1M
- cache_refresh_secs = 30, % seconds (auto zero when debug)
- include_dir = [], %% list of inc dirs for .yaws files
- phpexe = "php", %% cgi capable php executable
- yaws, %% server string
- username, %% maybe run as a different user than root
- uid, %% unix uid of user that started yaws
- id = "default" %% string identifying this instance of yaws
+ yaws_dir, % topdir of Yaws installation
+ trace, % false | {true,http} | {true,traffic}
+ flags = ?GC_DEF, % boolean flags
+ logdir,
+ ebin_dir = [],
+ runmods = [], % runmods for entire server
+ keepalive_timeout = 30000,
+ keepalive_maxuses = nolimit, % nolimit or non negative integer
+ max_num_cached_files = 400,
+ max_num_cached_bytes = 1000000, % 1 MEG
+ max_size_cached_file = 8000,
+ max_connections = nolimit, % max number of TCP connections
+
+ %% Override default connection handler processes spawn options for
+ %% performance/memory tuning.
+ %% [] | [{fullsweep_after,Number}, {min_heap_size, Size}]
+ %% other options such as monitor, link are ignored.
+ process_options = [],
+
+ large_file_chunk_size = 10240,
+ mnesia_dir = [],
+ log_wrap_size = 10000000, % wrap logs after 10M
+ cache_refresh_secs = 30, % seconds (auto zero when debug)
+ include_dir = [], % list of inc dirs for .yaws files
+ phpexe = "/usr/bin/php-cgi", % cgi capable php executable
+
+ yaws, % server string
+ id = "default", % string identifying this instance of yaws
+
+ enable_soap = false, % start yaws_soap_srv iff true
+
+ %% a list of
+ %% {{Mod, Func}, WsdlFile, Prefix} | {{Mod, Func}, WsdlFile}
+ %% automatically setup in yaws_soap_srv init.
+ soap_srv_mods = [],
+
+ ysession_mod = yaws_session_server, % storage module for ysession
+ acceptor_pool_size = 8, % size of acceptor proc pool
+
+ mime_types_info % undefined | #mime_types_info{}
}).
</verbatim>
@@ -198,27 +223,56 @@ out(A) ->
<div class="box">
<verbatim>
+
%% server conf
- -record(sconf,
- {port = 8000, %% which port is this server listening to
- flags = ?SC_DEF,
- rhost, %% forced redirect host (+ optional port)
- rmethod, %% forced redirect method
- docroot, %% path to the docs
- listen = {127,0,0,1}, %% bind to this IP, {0,0,0,0} is possible
- servername = "localhost", %% servername is what Host: header is
- ets, %% local store for this server
- ssl,
- authdirs = [],
- partial_post_size = nolimit,
- appmods = [], %% list of modules for this app
- errormod_404 = yaws_404, %% the default 404 error module
- errormod_crash = yaws_404, %% use the same module for crashes
- arg_rewrite_mod = yaws,
- opaque = [], %% useful in embedded mode
- start_mod, %% user provided module to be started
- allowed_scripts = [yaws],
- revproxy = []
+ -record(sconf, {
+ port = 8000, % which port is this server listening to
+ flags = ?SC_DEF,
+ redirect_map=[], % a list of
+ % {Prefix, #url{}, append|noappend}
+ % #url{} can be partially populated
+
+ rhost, % forced redirect host (+ optional port)
+ rmethod, % forced redirect method
+ docroot, % path to the docs
+ xtra_docroots = [], % if we have additional pseudo docroots
+ listen = [{127,0,0,1}], % bind to this IP, {0,0,0,0} is possible
+ servername = "localhost", % servername is what Host: header is
+ yaws, % server string for this vhost
+ ets, % local store for this server
+ ssl, % undefined | #ssl{}
+ authdirs = [], % [{docroot, [#auth{}]}]
+ partial_post_size = 10240,
+
+ %% An item in the appmods list can be either of the
+ %% following, this is all due to backwards compat issues.
+ %% 1. an atom - this is the equivalent to {atom, atom}
+ %% 2 . A two tuple {Path, Mod}
+ %% 3 A three tuple {Path, Mod, [ExcludeDir ....]}
+ appmods = [],
+
+ expires = [],
+ errormod_401 = yaws_outmod, % the default 401 error module
+ errormod_404 = yaws_outmod, % the default 404 error module
+ errormod_crash = yaws_outmod, % use the same module for crashes
+ arg_rewrite_mod = yaws,
+ logger_mod = yaws_log, % access/auth logging module
+ opaque = [], % useful in embedded mode
+ start_mod, % user provided module to be started
+ allowed_scripts = [yaws,php,cgi,fcgi],
+ tilde_allowed_scripts = [],
+ index_files = ["index.yaws", "index.html", "index.php"],
+ revproxy = [],
+ soptions = [],
+ extra_cgi_vars = [],
+ stats, % raw traffic statistics
+ fcgi_app_server, % FastCGI application server {host,port}
+ php_handler = {cgi, "/usr/bin/php-cgi"},
+ shaper,
+ deflate_options, % undefined | #deflate{}
+ mime_types_info, % undefined | #mime_types_info{}
+ % if undefined, global config is used
+ dispatch_mod % custom dispatch module
}).
</verbatim>

0 comments on commit 48c0510

Please sign in to comment.