Permalink
Browse files

1. Fixed so that the HTTP status is set to 401 explicitly in

yaws_server:handle_ut(...), previously out401 needed to return
{status, ...} or status would default to 200.

2. Changed outmod:out401(...) so that it returns {ehtml, ...} instead of
{status, ...}

3. Documented the errmormod_401 option in the man page.
  • Loading branch information...
faal committed Apr 24, 2009
1 parent f27ca2c commit 3c41877993fa92251e39df2ecb3c878ea9d46463
Showing with 19 additions and 3 deletions.
  1. +14 −0 man/yaws.conf.5
  2. +1 −3 src/yaws_outmod.erl
  3. +4 −0 src/yaws_server.erl
View
@@ -332,6 +332,20 @@ SC is a #sconf{} record (defined in yaws.hrl)
The function can and must do the same things that
a normal \fIout/1\fR does.
+.TP
+\fBerrormod_401 = Module\fR
+It is possible to set a special module that handles
+401 Unauthorized messages. This can for example be used
+to display a login page instead.
+
+The function \fIModule:out401(Arg)\fR will
+be invoked. The arguments are
+
+Arg is a #arg{} record
+
+The function can and must do the same things that
+a normal \fIout/1\fR does.
+
.TP
\fBerrormod_crash = Module\fR
View
@@ -44,8 +44,6 @@ out404(Arg, GC, SC) ->
out401(_Arg) ->
- [{status, 401},
- %{header, ["WWW-Authenticate:", "Negotiate\r\n", "WWW-Authenticate: ", "Basic realm=\"\""]},
{ehtml,
[{html,[],
[
@@ -56,7 +54,7 @@ out401(_Arg) ->
]
}
]
- } ].
+ }.
not_found_body(Path, _GC, _SC) ->
L = ["<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"
View
@@ -1664,6 +1664,10 @@ handle_ut(CliSock, ARG, UT = #urltype{type = unauthorized}, N) ->
H = ARG#arg.headers,
SC = get(sc),
yaws:outh_set_dyn_headers(Req, H, UT),
+
+ %% outh_set_dyn headers sets status to 200 by default
+ %% so we need to set it 401
+ yaws:outh_set_status_code(401),
deliver_dyn_part(CliSock,
0,
"appmod",

0 comments on commit 3c41877

Please sign in to comment.