Permalink
Browse files

Move WebDAV to an appmod, the locking server to a runmod (tjeerd)

All WebDAV functionality is moved to an appmod so the extension methods and
additional response headers are not part of yaws_server.erl and yaws.erl
anymore. Also the locking server is now a runmod so it is not started by
the supervisor and can be used only when needed.

Additionally the 100-Continue code is moved so it can be returned to all
requests that contain a body.

The WebDAV functionality is tested against the litmus test. All tests are
passed, except the ones that require unsupported properties. The test shows
this as a fail while returning 404 should be sufficient.
  • Loading branch information...
1 parent b6b38a6 commit a6706ebeeb49db466dd58474e13d518f4f32049c @vinoski vinoski committed Mar 25, 2013
Showing with 1,553 additions and 1,276 deletions.
  1. +22 −5 doc/yaws.tex
  2. +5 −17 include/yaws_dav.hrl
  3. +18 −0 include/yaws_lock.hrl
  4. +3 −3 src/Makefile
  5. +2 −12 src/yaws.erl
  6. +1,327 −0 src/yaws_appmod_dav.erl
  7. +19 −2 src/yaws_config.erl
  8. +0 −1,062 src/yaws_dav.erl
  9. +145 −111 src/{yaws_davlock.erl → yaws_runmod_lock.erl}
  10. +11 −60 src/yaws_server.erl
  11. +1 −4 src/yaws_sup.erl
View
@@ -2685,11 +2685,28 @@ \section{Server Part}
dangerous.
\item \verb+dav = true | false+ ---
- Turns on the DAV protocol for this server. The dav support in
- \Yaws\ is highly limited. If dav is turned on, .yaws processing of
- .yaws pages is turned off. Default is false. The socket read
- timeout is supplied by the keepalive\_timeout setting. If the read
- is not done within the timeout, the POST will fail.
+ Turns on the WebDAV protocol for this server. The WebDAV support adds
+ class 1, 2 and 3 compliancy which includes:
+ \begin{itemize}
+ \item XML request body parsing and multistatus responses
+ \item PROPFIND and PROPPATCH methods returning properties asked for
+ \item all RFC4918 properties, the Apache executable property plus
+ some Microsoft extensions
+ \item locking mechanism (class 2 compliancy) on all destructive methods
+ \item If header parsing
+ \item Passes most litmus tests, except those concerning unknown
+ properties
+ \end{itemize}
+ If WebDAV is turned on, processing of \verb+.yaws+ pages is turned off.
+ Default is false. The \verb+dav=true+ configuration option is short for:
+\begin{verbatim}
+ runmod = yaws_runmod_lock
+ ...
+ <server>
+ ...
+ appmods = </, yaws_appmod_dav>
+ <server>
+\end{verbatim}
\item \verb+tilde_expand = true|false+ ---
If this value is set to false \Yaws\ will
View
@@ -1,26 +1,14 @@
-ifndef(_YAWS_DAV).
-define(_YAWS_DAV, true).
--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()
+-record(upload, {
+ fd,
+ tempname,
+ filename
}).
-
+
-endif.
View
@@ -0,0 +1,18 @@
+-ifndef(_YAWS_LOCK).
+-define(_YAWS_LOCK, true).
+
+-define(LOCK_LIFETIME, 900). % lock lifetime in seconds: 15 minutes
+-define(CLEANUP_INTERVAL, 60). % cleanup interval in seconds: 1 minute
+
+-record(lock,{
+ 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.
View
@@ -41,8 +41,8 @@ MODULES=yaws \
yaws_html \
yaws_log_file_h \
yaws_rss \
- yaws_dav \
- yaws_davlock \
+ yaws_appmod_dav \
+ yaws_runmod_lock \
yaws_pam \
json json2 jsonrpc yaws_jsonrpc yaws_xmlrpc\
haxe yaws_rpc \
@@ -72,7 +72,7 @@ ERLC_FLAGS+=-Werror $(DEBUG_FLAGS) -pa ../../yaws -I ../include
all: yaws_generated.erl yaws_configure.hrl $(EBIN_FILES)
dav:
- $(MAKE) MODULES="$(MODULES) yaws_dav"
+ $(MAKE) MODULES="$(MODULES) yaws_appmod_dav yaws_runmod_lock"
$(EBIN_FILES) : ../include/yaws.hrl ../include/yaws_api.hrl
View
@@ -1424,14 +1424,7 @@ make_allow_header() ->
make_allow_header(Options) ->
case Options of
[] ->
- HasDav = ?sc_has_dav(get(sc)),
- ["Allow: GET, POST, OPTIONS, HEAD",
- case HasDav of
- true ->
- ", PUT, DELETE, PROPFIND, PROPPATCH, MKCOL, MOVE, COPY";
- false ->
- ""
- end, "\r\n"];
+ ["Allow: GET, POST, OPTIONS, HEAD\r\n"];
_ ->
["Allow: ",
lists:foldl(fun(M, "") -> atom_to_list(M);
@@ -1441,14 +1434,11 @@ make_allow_header(Options) ->
end.
make_server_header() ->
Sc = get(sc),
- HasDav = ?sc_has_dav(Sc),
Signature = case Sc#sconf.yaws of
undefined -> (get(gc))#gconf.yaws;
S -> S
end,
- ["Server: ", Signature, "\r\n" | if HasDav == true -> ["DAV: 1, 2, 3\r\n"];
- true -> []
- end].
+ ["Server: ", Signature, "\r\n"].
make_last_modified_header(FI) ->
Then = FI#file_info.mtime,
Oops, something went wrong.

0 comments on commit a6706eb

Please sign in to comment.