Permalink
Browse files

Merge branch 'master' of github.com:klacke/yaws

  • Loading branch information...
klacke committed Oct 15, 2012
2 parents e3c1631 + 039c300 commit 128b00245f251ac4c00dca65fd3d0181fea1be06
Showing with 6,463 additions and 2,749 deletions.
  1. +4 −3 .gitignore
  2. +2 −2 Makefile
  3. +1 −0 configure.in
  4. +112 −11 doc/yaws.tex
  5. +11 −5 examples/src/server_sent_events.erl
  6. +17 −5 include/yaws.hrl
  7. +15 −14 include/yaws_api.hrl
  8. +19 −4 include/yaws_dav.hrl
  9. +5 −6 known_dialyzer_warnings
  10. +1 −2 man/yaws.1
  11. +159 −56 man/yaws.conf.5
  12. +149 −35 man/yaws_api.5
  13. +2 −11 man/yaws_soap_lib.5
  14. +1,413 −79 priv/mime.types
  15. +5 −0 rebar.config
  16. +44 −0 rel/files/install_upgrade.escript
  17. +125 −20 rel/files/yaws
  18. +2 −1 rel/reltool.config
  19. +1 −1 scripts/darwin/Yaws.StartupItem
  20. +35 −0 scripts/freebsd/yaws
  21. +1 −1 scripts/freebsd/yaws.sh
  22. +5 −5 scripts/rebar-pre-script
  23. +9 −8 src/Makefile
  24. +0 −1,357 src/mime.types
  25. +234 −125 src/mime_type_c.erl
  26. +215 −59 src/yaws.erl
  27. +414 −171 src/yaws_api.erl
  28. +4 −4 src/yaws_cgi.erl
  29. +359 −99 src/yaws_config.erl
  30. +876 −361 src/yaws_dav.erl
  31. +355 −0 src/yaws_davlock.erl
  32. +2 −2 src/yaws_exhtml.erl
  33. +16 −10 src/yaws_revproxy.erl
  34. +188 −150 src/yaws_server.erl
  35. +96 −22 src/yaws_soap12_lib.erl
  36. +1 −1 src/yaws_sse.erl
  37. +4 −1 src/yaws_sup.erl
  38. +31 −23 src/yaws_websockets.erl
  39. +1 −1 test/Makefile
  40. +109 −0 test/conf/davconf.conf
  41. +128 −0 test/conf/mimetypes.conf
  42. +26 −0 test/conf/stdconf.conf
  43. +2 −2 test/eunit/Makefile
  44. +40 −0 test/eunit/cookies.dump
  45. +348 −0 test/eunit/cookies.erl
  46. +0 −24 test/eunit/embedded_yaws_id_dir.erl
  47. +128 −0 test/eunit/ipmask.erl
  48. +236 −0 test/eunit/setcookies.dump
  49. +2 −2 test/support/include.mk.in
  50. +1 −1 test/t2/Makefile
  51. +165 −31 test/t2/app_test.erl
  52. +17 −0 test/t2/dispatchmod_tester.erl
  53. +3 −1 test/t2/posttest.erl
  54. +62 −0 test/t2/www/test_upload_ssl.yaws
  55. +1 −1 test/t3/app_test.erl
  56. +21 −23 test/t4/app_test.erl
  57. +2 −1 test/t4/posttest.erl
  58. +1 −1 test/t5/app_test.erl
  59. 0 test/t7/.placeholder
  60. +33 −0 test/t7/Makefile
  61. +118 −0 test/t7/app_test.erl
  62. +3 −0 test/t7/mime.types
  63. +28 −0 test/t8/Makefile
  64. +33 −0 test/t8/davtest
  65. +15 −0 test/t8/davtest.in
  66. +1 −0 test/t8/www/test
  67. +1 −0 www/contributors.txt
  68. +4 −5 www/json_sample.yaws
  69. +0 −1 www/news
  70. +2 −1 www/server_sent_events.html
View
@@ -16,8 +16,8 @@ config.status
ebin/yaws.app
include.mk
priv/epam
+priv/charset.def
scripts/yaws.conf
-src/charset.def
src/mime_types.erl
src/yaws_configure.hrl
src/yaws_generated.erl
@@ -26,8 +26,8 @@ test/ibrowse.tar.gz
test/support/include.mk
test/support/include.sh
test/t1/localhost:8000/
-test/t[123456]/logs/
-test/t[123456]/yaws.conf
+test/t[12345678]/logs/
+test/t[12345678]/yaws.conf
test/t4/www2/8388608.bin
www/yaws.pdf
www/yaws.ps
@@ -72,3 +72,4 @@ yaws_logs
rel/yaws
dialyzer_warnings
deps/*
+.eunit/*
View
@@ -79,7 +79,7 @@ touch:
find . -name '*.erl' -print | xargs touch -m
yaws.plt:
- dialyzer --build_plt -r ebin src --output_plt yaws.plt \
+ dialyzer --build_plt -r ebin --output_plt yaws.plt \
-r $(ERLDIR)/lib/sasl-$(SASL_VSN) \
-r $(ERLDIR)/lib/kernel-$(KERNEL_VSN) \
-r $(ERLDIR)/lib/stdlib-$(STDLIB_VSN) \
@@ -89,7 +89,7 @@ yaws.plt:
# -r $(ERLDIR)/lib/ssl-$(SSL_VSN)
dialyzer: yaws.plt
- -dialyzer -q --plt yaws.plt -r ebin src > dialyzer_warnings
+ -dialyzer -q --plt yaws.plt -r ebin > dialyzer_warnings
diff -U0 known_dialyzer_warnings dialyzer_warnings
.PHONY: test
View
@@ -237,6 +237,7 @@ case "$host_os" in
[AC_MSG_NOTICE(found 32-bit Erlang)
case "$host_cpu" in
i?86) CBIT= ;;
+ armv6l) CBIT= ;;
*) CBIT=-m32 ;;
esac])
CFLAGS="$CFLAGS $CBIT"
View
@@ -1547,7 +1547,7 @@ \section{Stream content}
{streamcontent_from_pid, MimeType, Pid}
\end{verbatim}
-\noindent to tell \Yaws\ we wish to deliver data of mime type
+\noindent to tell \Yaws\ we wish to deliver data of MIME type
\verb+MimeType+ to the client from process \verb+Pid+. In this case,
\Yaws\ will prepare the socket for delivery from \verb+Pid+ and then
send one of the following messages to \verb+Pid+:
@@ -2192,8 +2192,8 @@ \section{Global Part}
\Yaws{}.
\item \verb+use_old_ssl = true | false+ ---
- This re-enables the old OTP ssl implementation. By default we use
- the new ssl implementation.
+ This re-enables the old OTP SSL implementation. By default we use
+ the new SSL implementation.
\item \verb+auth_log = true | false+ ---
\textit{Deprecated and ignored. Now, this target must be set in
@@ -2319,6 +2319,50 @@ \section{Global Part}
\item \verb+x_forwarded_for_log_proxy_whitelist = ListOfUpstreamProxyServerIps+ ---
\textit{This target is deprecated and will be ignored}.
+\item \verb+default_type = MimeType+ ---
+ Defines the default MIME type to be used where \Yaws\ cannot
+ determine it by its MIME types mappings. Default is
+ \textit{text/plain}.
+
+\item \verb+default_charset = Charset+ ---
+ Defines the default charset to be added when a response
+ content-type is \textit{text/*}. By default, no charset is added.
+
+\item \verb+mime_types_file = File+ ---
+ Overloads the default \textit{mime.types} file included with
+ \Yaws{}. This file must use the following format:
+\begin{verbatim}
+ # Lines beginning with a '#' or a whitespace are ignored
+ # blank lines are also ignored
+ <MIME type> <space separated file extensions>
+\end{verbatim}
+ The default file is located at
+ \textit{\${PREFIX}/lib/yaws/priv/mime.types}. You should not edit
+ this file because it may be replaced when you upgrade your server.
+
+\item \verb+add_types = ListOfTypes+ ---
+ Specifies one or more mappings between MIME types and file
+ extensions. More than one extension can be assigned to a MIME
+ type. \textit{ListOfTypes} is defined as follows:
+\begin{verbatim}
+ add_types = <MimeType1, Ext> <MimeType2, Ext1 Ext2 ...> ...
+\end{verbatim}
+ The mappings defined using this directive will overload all other
+ definitions. If a file extension is defined several times, only
+ the last one is kept. Multiple \textit{add\_types} directives may
+ be used.
+
+\item \verb+add_charsets = ListOfCharsets+ ---
+ Specifies one or more mappings between charsets and file
+ extensions. More than one extension can be assigned to a
+ charset. \textit{ListOfCharsets} is defined as follows:
+\begin{verbatim}
+ add_charsets = <Charset1, Ext> <Charset2, Ext1 Ext2 ...> ...
+\end{verbatim}
+ The mappings defined using this directive will overload all other
+ definitions. If a file extension is defined several times, only
+ the last one is kept. Multiple \textit{add\_charsets} directives
+ may be used.
\end{itemize}
@@ -2340,12 +2384,13 @@ \section{Server Part}
This makes the server listen on Port. Default is 8000.
\item \verb+listen = IpAddress+ ---
- This makes the server listen on \verb+IpAddress+ when
- virthosting several servers on the same IP/port
- address, if the browser doesn't send a \verb+Host:+ field,
- \Yaws\ will pick the first server specified in the
- config file. Multiple \verb+listen+ directives may be
- used to specify several addresses to listen on.
+ This makes the server listen on \verb+IpAddress+ when
+ virthosting several servers on the same IP/port address, if
+ the browser doesn't send a \verb+Host:+ field, \Yaws\ will
+ pick the first server specified in the config file. Multiple
+ \verb+listen+ directives may be used to specify several
+ addresses to listen on. The default listen interface is
+ 127.0.0.1.
\item \verb+listen_backlog = Integer+ ---
This sets the TCP listen backlog for the server to
@@ -2612,6 +2657,13 @@ \section{Server Part}
\textit{cgi}, \textit{fcgi}, \textit{php}. Default is\\
\verb+tilde_allowed_scripts =+ (i.e., empty).
+\item \verb+index_files = ListOfResources+ ---
+ This directive sets the list of resources to look for, when a
+ directory is requested by the client. If the last entry begins with
+ a `/', and none of the earlier resources are found, \Yaws\ will
+ perform a redirect to this uri.\\
+ Default is \verb+index_files = index.yaws index.html index.php+.
+
\item \verb+appmods = ListOfModuleNames+ ---
If any the names in \verb+ListOfModuleNames+ appear as components
in the path for a request, the path request parsing will terminate
@@ -2640,6 +2692,30 @@ \section{Server Part}
on everything except any file found in directories \verb+icons+,
\verb+js+ and \verb+top/static+ relative to the docroot.
+\item \verb+dispatchmod = DispatchModule+ ---
+ Set \verb+DispatchModule+ as a server-specific request
+ dispatching module. \Yaws\ expects \verb+DispatchModule+ to
+ export a \verb+dispatch/1+ function. When it receives a
+ request, \Yaws\ passes an \verb+#arg{}+ record to the dispatch
+ module's \verb+dispatch/1+ function, which returns one of the
+ following atom results:
+ \begin{itemize}
+ \item \verb+done+ --- this indicates the dispatch module
+ handled the request itself and already sent the response,
+ and \Yaws\ should resume watching for new requests on the
+ connection
+ \item \verb+closed+ --- same as \verb+done+ but the
+ \verb+DispatchModule+ also closed the connection
+ \item \verb+continue+ --- the dispatch module has decided
+ not to handle the request, and instead wants \Yaws\ to
+ perform its regular request dispatching
+ \end{itemize}
+ Note that when \verb+DispatchModule+ handles a request itself,
+ \Yaws\ does not support tracing, increment statistics
+ counters or allow traffic shaping for that request. It does
+ however still keep track of maximum keepalive uses on the
+ connection.
+
\item \verb+errormod_404 = Module+ ---
It is possible to set a special module that handles 404 Not Found
messages. The function\\ \verb+Module:out404(Arg, GC, SC)+ will be
@@ -2852,6 +2928,31 @@ \section{Server Part}
Use this directive is same as:
\verb+php_handler = <fcgi, HostPortSpec>+.
+\item \verb+default_type = MimeType+ ---
+ Overloads the global \verb+default_type+ value for this virtual
+ server.
+
+\item \verb+default_charset = Charset+ ---
+ Overloads the global \verb+default_charset+ value for this virtual
+ server.
+
+\item \verb+mime_types_file = File+ ---
+ Overrides the global \verb+mime_type_file+ value for this virtual
+ server. Mappings defined in \textit{File} will not overload those
+ defined by \verb+add_types+ directives in the global part.
+
+\item \verb+add_types = ListOfTypes+ ---
+ Overloads the global \verb+add_types+ values for this virtual
+ server. If a mapping is defined in the global part and redefined
+ in a server part using this directive, then it is replaced. Else
+ it is kept.
+
+\item \verb+add_charsets = ListOfCharsets+ ---
+ Overloads the global \verb+add_charsets+ values for this virtual
+ server. If a mapping is defined in the global part and redefined
+ in a server part using this directive, then it is replaced. Else
+ it is kept.
+
\item \verb+<ssl> .... </ssl>+
This begins and ends an SSL configuration for this server. It's
possible to virthost several SSL servers on the same IP given
@@ -2903,7 +3004,7 @@ \section{Server Part}
\item \verb+depth = Int+ --- Specifies the depth of certificate
chains the server is prepared to follow when verifying client
- certs. For the OTP new ssl implementation it is also used to
+ certs. For the OTP new SSL implementation it is also used to
specify how far the server, i.e. we, shall follow the SSL
certificates we present to the clients. Hence, using self
signed certs, we typically need to set this to 0.
@@ -2954,7 +3055,7 @@ \section{Server Part}
</redirect>
\end{verbatim}
With this configuration, a request for
- \url{http://abc.com/foo/x/y/z} simply gets redirected to
+ \url{http://abc.com/foo/x/y/z} simply gets redirected to \\
\url{http://www.mysite.org/zapp}. This is typically used when
we simply want a static redirect at some place in the
docroot.
@@ -38,7 +38,8 @@ out(A) ->
end
end;
_ ->
- {status, 405}
+ [{status, 405},
+ {header, {"Allow", "GET"}}]
end.
init([Arg]) ->
@@ -51,8 +52,7 @@ handle_call(_Request, _From, State) ->
handle_cast(_Msg, State) ->
{noreply, State}.
-handle_info({ok, YawsPid}, #state{sock=Socket}=State) ->
- ok = inet:setopts(Socket, [{active, once}]),
+handle_info({ok, YawsPid}, State) ->
{ok, Timer} = timer:send_interval(1000, self(), tick),
{noreply, State#state{yaws_pid=YawsPid, timer=Timer}};
handle_info({discard, _YawsPid}, State) ->
@@ -61,8 +61,14 @@ handle_info({discard, _YawsPid}, State) ->
handle_info(tick, #state{sock=Socket}=State) ->
Time = erlang:localtime(),
Data = yaws_sse:data(httpd_util:rfc1123_date(Time)),
- yaws_sse:send_events(Socket, Data),
- {noreply, State};
+ case yaws_sse:send_events(Socket, Data) of
+ ok ->
+ {noreply, State};
+ {error, closed} ->
+ {stop, normal, State};
+ {error, Reason} ->
+ {stop, Reason, State}
+ end;
handle_info({tcp_closed, _}, State) ->
{stop, normal, State#state{sock=closed}};
handle_info(_Info, State) ->
View
@@ -97,10 +97,10 @@
soap_srv_mods = [],
ysession_mod = yaws_session_server, % storage module for ysession
- acceptor_pool_size = 8 % size of acceptor proc pool
- }).
-
+ acceptor_pool_size = 8, % size of acceptor proc pool
+ mime_types_info
+ }).
-record(ssl, {
keyfile,
@@ -233,14 +233,17 @@
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
+ deflate_options,
+ mime_types_info, % if undefined, global config is used
+ dispatch_mod % custom dispatch module
}).
@@ -288,6 +291,16 @@
}).
+%% Internal record used to set information about mime-types
+-record(mime_types_info, {
+ mime_types_file, % an absolute filename path
+ types = [], % a map between mime-types and extensions
+ charsets = [], % a map between charsets and extensions
+ default_type = "text/plain",
+ default_charset
+ }).
+
+
%% this internal record is used and returned by the URL path parser
-record(urltype, {
type, % error | yaws | regular | directory | forbidden |
@@ -348,7 +361,6 @@
}).
-
%% as read by application:get_env()
-record(env, {
debug,
View
@@ -87,20 +87,21 @@
querypart = []}).
--record(setcookie,{
- key,
- value,
- quoted,
- comment,
- comment_url,
- discard,
- domain,
- max_age,
- expires,
- path,
- port,
- secure,
- version}).
+-record(setcookie, {key,
+ value,
+ quoted = false,
+ domain,
+ max_age,
+ expires,
+ path,
+ secure = false,
+ http_only = false,
+ extensions = []}).
+
+
+-record(cookie, {key,
+ value,
+ quoted = false}).
-record(redir_self, {
View
@@ -1,11 +1,26 @@
-ifndef(_YAWS_DAV).
-define(_YAWS_DAV, true).
--record(propfind, {
- prop = [],
- uri = ""
- }).
+-define(LOCK_LIFETIME, 900). % lock lifetime in seconds: 15 minutes
+-define(CLEANUP_INTERVAL, 60). % cleanup interval in seconds: 1 minute
+-define(elog(X,Y), error_logger:info_msg("*elog ~p:~p: " X,
+ [?MODULE, ?LINE | Y])).
+-record(resource,{
+ name, % normalized name of resource
+ info % file_info record of mapped file
+ }).
+
+-record(davlock,{
+ path=undefined, % resource path
+ id=undefined, % uid
+ owner=anonymous, % lock owner if submitted
+ depth=infinity, % 0|infinity
+ scope=exclusive, % exclusive|shared
+ type=write, % write
+ timeout=0, % ?LOCK_LIFETIME or shorter
+ timestamp=0 % erlang:now()
+ }).
-endif.
Oops, something went wrong.

0 comments on commit 128b002

Please sign in to comment.