Permalink
Browse files

cache_refresh to 0 if debug, added a cookie_session-server for persis…

…tant cookie sessions

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@173 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent abc3a43 commit 80771c8649344a00db5900b9ab00d8d61b61554d @klacke committed Sep 17, 2002
Showing with 378 additions and 101 deletions.
  1. +12 −0 include/yaws_api.hrl
  2. +2 −1 src/Makefile
  3. +26 −4 src/yaws_api.erl
  4. +17 −2 src/yaws_config.erl
  5. +1 −23 src/yaws_server.erl
  6. +313 −0 src/yaws_session_server.erl
  7. +5 −1 src/yaws_sup.erl
  8. +2 −70 www/api.yaws
View
@@ -51,3 +51,15 @@
+%% portal server has a queue of these
+-record(ysession,
+ {cookie, %% the cookie assigned to the session
+ auth, %% the #auth structure as returned from portal_auth
+ to, %% greg secs untill timeout death
+ user, %% The user name
+ passwd, %% And the passwd of that user
+ starttime, %% When calendar:local_time() did sess start
+ opaque %% any data the user supplies
+ }).
+
+
View
@@ -22,7 +22,8 @@ MODULES=yaws \
yaws_ssl \
yaws_vsn \
mime_type_c \
- mime_types
+ mime_types \
+ yaws_session_server
EBIN_FILES=$(MODULES:%=../ebin/%.$(EMULATOR)) ../ebin/yaws.app
View
@@ -19,6 +19,10 @@
-export([find_cookie_val/2, secs/0, url_decode/1]).
-export([get_line/1, mime_type/1]).
-export([stream_chunk_deliver/2, stream_chunk_end/1]).
+-export([new_cookie_session/3,
+ cookieval_to_session/1,
+ print_cookie_sessions/0,
+ replace_cookie_session/2]).
%% these are a bunch of function that are useful inside
%% yaws scripts
@@ -511,7 +515,7 @@ setcookie(_Name, _Value, _Path, _Expire, _Domain, _Secure) ->
-%% This function can be passed the cookie we get in the Arg#arg.cookies
+%% This function can be passed the cookie we get in the Arg#arg.headers.cookies
%% to search for a specific cookie
%% return [] if not found
%% Str if found
@@ -597,17 +601,35 @@ get_line("\r\n" ++ Tail, Cur) ->
get_line([H|T], Cur) ->
get_line(T, [H|Cur]).
+
+
mime_type(FileName) ->
{_, MT} = mime_types:t(filename:extension(FileName)),
MT.
-
-
-
stream_chunk_deliver(YawsPid, Data) ->
YawsPid ! {streamcontent, Data}.
stream_chunk_end(YawsPid) ->
YawsPid ! endofstreamcontent.
+
+
+
+new_cookie_session(User, Passwd, Opaque) ->
+ yaws_session_server:new_session(User, Passwd, Opaque).
+
+%% as returned in #ysession.cookie
+cookieval_to_session(CookieVal) ->
+ yaws_session_server:cookieval_to_session(CookieVal).
+
+print_cookie_sessions() ->
+ yaws_session_server:print_sessions().
+
+replace_cookie_session(Session, User) ->
+ yaws_session_server:replace_session(Session, User).
+
+
+
+
View
@@ -41,7 +41,7 @@ load({file, File}, Trace, Debug) ->
yaws_log:infolog("Using config file ~s", [File]),
case file:open(File, [read]) of
{ok, FD} ->
- GC = make_default_gconf(),
+ GC = make_default_gconf(Debug),
R = (catch fload(FD, globals, GC#gconf{file = File,
trace = Trace,
debug = Debug
@@ -153,12 +153,18 @@ add_port(C, Port) ->
end.
-make_default_gconf() ->
+make_default_gconf(Debug) ->
Y = yaws_dir(),
#gconf{yaws_dir = Y,
ebin_dir = [filename:join([Y, "examples/ebin"])],
include_dir = [filename:join([Y, "examples/include"])],
logdir = ".",
+ cache_refresh_secs = if
+ Debug == true ->
+ 0;
+ true ->
+ 30
+ end,
uid = os:cmd("id -u") -- [10],
yaws = "Yaws " ++ yaws_vsn:version()}.
@@ -302,6 +308,15 @@ fload(FD, server, GC, C, Cs, Lno, Chars) ->
case toks(Chars) of
[] ->
fload(FD, server, GC, C, Cs, Lno+1, Next);
+
+ ["access_log", '=', Bool] ->
+ case is_bool(Bool) of
+ {true, Val} ->
+ C2 = C#sconf{access_log = 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) ->
View
@@ -1789,7 +1789,7 @@ url_type(GC, SC, Path) ->
FI = UT#urltype.finfo,
Refresh = GC#gconf.cache_refresh_secs,
if
- ((N-When) > Refresh) ->
+ ((N-When) >= Refresh) ->
?Debug("Timed out entry for ~s ~p~n", [Path, {When, N}]),
%% more than 30 secs old entry
ets:delete(E, {url, Path}),
@@ -2043,28 +2043,6 @@ drop_till_dot([]) ->
[].
-
-
-% %% FIXME add all mime types here
-% suffix_type("sway." ++ _) ->
-% {yaws, "text/html"};
-% suffix_type("lmth." ++ _) ->
-% {regular, "text/html"};
-% suffix_type("gpj." ++ _) ->
-% {regular, "image/jpeg"};
-% suffix_type("gnp." ++ _) ->
-% {regular, "image/png"};
-% suffix_type("fig." ++ _) ->
-% {regular, "image/gif"};
-% suffix_type("3pm." ++ _) ->
-% {regular, "audio/mpeg"};
-% suffix_type("zg." ++ _) ->
-% {regular, "application/x-gzip"};
-% suffix_type(_) ->
-% {regular, "application/octet-stream"}.
-
-
-
flush(SC, Sock, Sz) ->
case SC#sconf.ssl of
undefined ->
Oops, something went wrong.

0 comments on commit 80771c8

Please sign in to comment.