Skip to content
Browse files

page retval

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@265 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent ca970bc commit c837288076df51677de7741c7097860b138d277e @klacke committed Nov 12, 2002
Showing with 27 additions and 9 deletions.
  1. +7 −0 man/yaws_api.5
  2. +20 −9 src/yaws_server.erl
View
7 man/yaws_api.5
@@ -422,6 +422,13 @@ and be invoked again when more Data arrives.
.TP
+\fB{page, Page}\fR
+Make Yaws return a different page than the one being
+requested.
+
+
+
+.TP
\fB[ListOfValues]\fR
It is possible to return a list of the above defined
return values.
View
29 src/yaws_server.erl
@@ -596,8 +596,10 @@ aloop(CliSock, GS, Num) when GS#gs.ssl == nossl ->
aloop(CliSock, GS, Num+1);
done ->
{ok, Num+1};
- {page, _Page} ->
- nyi
+ {page, Page} ->
+ apply(yaws_server, Req#http_request.method,
+ [CliSock, GS#gs.gconf, SC#sconf{appmods=[]},
+ Req#http_request{path = {abs_path, Page}}, H])
end
end;
@@ -625,7 +627,11 @@ aloop(CliSock, GS, Num) when GS#gs.ssl == ssl ->
continue ->
aloop(CliSock, GS, Num+1);
done ->
- {ok, Num+1}
+ {ok, Num+1};
+ {page, Page} ->
+ apply(yaws_server, Req#http_request.method,
+ [CliSock, GS#gs.gconf, SC#sconf{appmods = []},
+ Req#http_request{path = {abs_path, Page}}, H])
end
end.
@@ -1266,7 +1272,8 @@ deliver_dyn_file(CliSock, GC, SC, Req, Head, UT, DCC, Bin, Fd, [H|T],ARG,N) ->
break ->
deliver_dyn_file(CliSock, GC, SC, Req, Head,
UT, DCC, Bin, Fd, [],ARG,N) ;
-
+ {page, Page} ->
+ {page, Page};
{streamcontent, MimeType, FirstChunk} ->
put(content_type, MimeType),
accumulate_chunk(DCC, FirstChunk),
@@ -1330,6 +1337,8 @@ stream_loop(DCC, CliSock, GC, SC) ->
stream_loop(DCC, CliSock, GC, SC) ;
endofstreamcontent ->
ok
+ after 30000 ->
+ exit(normal)
end.
@@ -1487,6 +1496,8 @@ handle_out_reply_l([Reply|T], DCC, LineNo, YawsFile, SC, A, Res) ->
handle_out_reply_l(T, DCC, LineNo, YawsFile, SC, A, {get_more, Cont, State});
break ->
break;
+ {page, Page} ->
+ {page, Page};
_ ->
handle_out_reply_l(T, DCC, LineNo, YawsFile, SC, A, Res)
end;
@@ -2084,13 +2095,13 @@ split_path(SC, [$/|Tail], Comps, Part) when Part /= [] ->
Component = lists:reverse(Part),
CName = tl(Component),
case lists:member(CName, SC#sconf.appmods) of
- false ->
- split_path(SC, [$/|Tail], [lists:reverse(Part) | Comps], []);
- true ->
+ true ->
%% we've found an appmod
PrePath = conc_path(Comps),
- ret_app_mod(SC, [$/|Tail], list_to_atom(CName), PrePath)
- end;
+ ret_app_mod(SC, [$/|Tail], list_to_atom(CName), PrePath);
+ _ ->
+ split_path(SC, [$/|Tail], [lists:reverse(Part) | Comps], [])
+ end;
split_path(SC, [$~|Tail], Comps, Part) -> %% user dir
ret_user_dir(SC, Comps, Part, Tail);
split_path(SC, [H|T], Comps, Part) ->

0 comments on commit c837288

Please sign in to comment.
Something went wrong with that request. Please try again.