Skip to content

Commit

Permalink
reworked the DAV support a bit - don't use an appmod, instead yaws ha…
Browse files Browse the repository at this point in the history
…s built-in support for DAV methods. Added support for missing DAV methods (COPY etc).

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@927 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information
Martin Bjorklund committed Nov 23, 2005
1 parent 6cf3ece commit 868ce8a
Show file tree
Hide file tree
Showing 7 changed files with 548 additions and 291 deletions.
18 changes: 11 additions & 7 deletions include/yaws.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,24 @@
-define(SC_DIR_LISTINGS, 16).
-define(SC_DEFLATE, 32).
-define(SC_DIR_ALL_ZIP, 64).

-define(SC_DAV, 128).

-define(SC_DEF, ?SC_ACCESS_LOG bor ?SC_ADD_PORT).

-define(sc_has_access_log(SC),
((SC#sconf.flags band ?SC_ACCESS_LOG) /= 0)).
(((SC)#sconf.flags band ?SC_ACCESS_LOG) /= 0)).
-define(sc_has_add_port(SC),
((SC#sconf.flags band ?SC_ADD_PORT) /= 0)).
(((SC)#sconf.flags band ?SC_ADD_PORT) /= 0)).
-define(sc_has_tilde_expand(SC),
((SC#sconf.flags band ?SC_TILDE_EXPAND) /= 0)).
(((SC)#sconf.flags band ?SC_TILDE_EXPAND) /= 0)).
-define(sc_has_dir_listings(SC),
((SC#sconf.flags band ?SC_DIR_LISTINGS) /= 0)).
(((SC)#sconf.flags band ?SC_DIR_LISTINGS) /= 0)).
-define(sc_has_deflate(SC),
((SC#sconf.flags band ?SC_DEFLATE) /= 0)).
(((SC)#sconf.flags band ?SC_DEFLATE) /= 0)).
-define(sc_has_dir_all_zip(SC),
((SC#sconf.flags band ?SC_DIR_ALL_ZIP) /= 0)).
(((SC)#sconf.flags band ?SC_DIR_ALL_ZIP) /= 0)).
-define(sc_has_dav(SC),
(((SC)#sconf.flags band ?SC_DAV) /= 0)).


-define(sc_set_access_log(SC, Bool),
Expand All @@ -133,6 +135,8 @@
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_DEFLATE, Bool)}).
-define(sc_set_dir_all_zip(SC, Bool),
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_DIR_ALL_ZIP, Bool)}).
-define(sc_set_dav(SC, Bool),
SC#sconf{flags = yaws:flag(SC#sconf.flags, ?SC_DAV, Bool)}).



Expand Down
3 changes: 1 addition & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ MODULES=yaws \
yaws_html \
yaws_log_file_h \
yaws_rss \
dav

yaws_dav


EBIN_FILES=$(MODULES:%=../ebin/%.$(EMULATOR)) ../ebin/yaws.app
Expand Down
267 changes: 0 additions & 267 deletions src/dav.erl

This file was deleted.

19 changes: 14 additions & 5 deletions src/yaws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1215,12 +1215,21 @@ dcc(Req, Headers) ->
%%

make_allow_header() ->
"Allow: GET, POST, PUT, OPTIONS, HEAD, PROPFIND, MKCOL\r\n".
HasDav = ?sc_has_dav(get(sc)),
["Allow: GET, POST, OPTIONS, HEAD",
if HasDav == true ->
", PUT, PROPFIND, MKCOL, MOVE, COPY\r\n";
false ->
"\r\n"
end].
make_server_header() ->
["Server: Yaws/", yaws_vsn:version(), " Yet Another Web Server\r\n",
"DAV: 1\r\n"].


HasDav = ?sc_has_dav(get(sc)),
["Server: Yaws/", yaws_vsn:version(), " Yet Another Web Server\r\n" |
if HasDav == true ->
["DAV: 1\r\n"];
true ->
[]
end].

make_last_modified_header(FI) ->
N = element(2, now()),
Expand Down
8 changes: 8 additions & 0 deletions src/yaws_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@ fload(FD, server, GC, C, Cs, Lno, Chars) ->
false ->
{error, ?F("Expect true|false at line ~w", [Lno])}
end;
["dav", '=', Bool] ->
case is_bool(Bool) of
{true, Val} ->
C2 = ?sc_set_dav(C, Val),
fload(FD, server, GC, C2, Cs, Lno+1, Next);
false ->
{error, ?F("Expect true|false at line ~w", [Lno])}
end;
["port", '=', Val] ->
case (catch list_to_integer(Val)) of
I when integer(I) ->
Expand Down
Loading

0 comments on commit 868ce8a

Please sign in to comment.