Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

""

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@261 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
commit 8d5aa60c477e57d6fb0e2874f242c61743aeaf70 1 parent a481526
@klacke authored
View
1  include/yaws.hrl
@@ -15,6 +15,7 @@
debug,
logdir,
ebin_dir = [],
+ runmods = [],
keepalive_timeout = 15000,
max_num_cached_files = 400,
max_num_cached_bytes = 1000000, %% 1 MEG
View
68 man/yaws_api.5
@@ -43,43 +43,45 @@ We have the following relevant record definitions:
.nf
-record(arg, {
- clisock, %% the socket leading to the peer client
- headers, %% headers
- req, %% request
- clidata, %% The client data (as a binary in POST requests)
- querydata, %% Was the URL on the form of ...?query (GET reqs)
- docroot, %% where's the data
- fullpath, %% full path to yaws file
- cont, %% Continuation for chunked multipart uploads
- state, %% State for use by users of the out/1 callback
- pid %% pid of the yaws process
- }).
+ clisock, %% the socket leading to the peer client
+ headers, %% headers
+ req, %% request
+ clidata, %% The client data (as a binary in POST requests)
+ querydata, %% Was the URL on the form of ...?query (GET reqs)
+ docroot, %% where's the data
+ fullpath, %% full path to yaws file
+ cont, %% Continuation for chunked multipart uploads
+ state, %% State for use by users of the out/1 callback
+ pid, %% pid of the yaws process
+ opaque %% useful to pass static data
+
+ }).
.fi
\fR
The headers argument is also a record:
\fI
.nf
-
+
-record(headers, {
- connection,
- accept,
- host,
- if_modified_since,
- if_match,
- if_none_match,
- if_range,
- if_unmodified_since,
- range,
- referer,
- user_agent,
- accept_ranges,
- cookie = [],
- keep_alive,
- content_length,
- authorization,
- other = [] %% misc other headers
- }).
+ connection,
+ accept,
+ host,
+ if_modified_since,
+ if_match,
+ if_none_match,
+ if_range,
+ if_unmodified_since,
+ range,
+ referer,
+ user_agent,
+ accept_ranges,
+ cookie = [],
+ keep_alive,
+ content_length,
+ authorization,
+ other = [] %% misc other headers
+ }).
.fi
\fR
@@ -301,7 +303,7 @@ Url-encodes a string. All URLs in HTML documents must be URL encoded.
.TP
-\freformat_header(H)\fR
+\fBreformat_header(H)\fR
Returns a list of reformated header values from a #header{}
record. The return list is suitable for retransmit.
@@ -326,9 +328,9 @@ is
.nf
EHTML = [EHTML] | {Tag, Attrs, Body} | {Tag, Attrs} | {Tag} |
binary() | character()
-Tag = atom()
+Tag = atom()
Attrs = [{Key, Value}] or {EventTag, {jscall, FunName, [Args]}}
-Key = atom()
+Key = atom()
Value = string()
Body = EHTML
.fi
View
2  src/yaws_api.erl
@@ -1,4 +1,4 @@
-%%%----------------------------------------------------------------------
+%%----------------------------------------------------------------------
%%% File : yaws_api.erl
%%% Author : Claes Wikstrom <klacke@hyber.org>
%%% Purpose :
View
5 src/yaws_config.erl
@@ -249,6 +249,11 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) ->
{error, ?F("Expect directory at line ~w", [Lno])}
end;
+ ["runmod", '=', Mod0] ->
+ Mod = list_to_atom(Mod0),
+ fload(FD, globals, GC#gconf{runmods = [Mod|GC#gconf.runmods]},
+ C, Cs, Lno+1, Next);
+
["include_dir", '=', Dir] ->
case is_dir(Dir) of
true ->
View
40 src/yaws_debug.erl
@@ -199,3 +199,43 @@ eprof() ->
+
+
+check_headers(L) ->
+ Hs = string:tokens(lists:flatten(L), "\r\n"),
+ io:format("XX ~p~n", [Hs]),
+ lists:foreach(
+ fun(H) ->
+ case lists:reverse(H) of
+ [_,_,$\r|_] ->
+ yaws_log:errlog("Bad header ~p, it contains"
+ " '\\r' or '\\n' at end ",
+ [lists:flatten(H)]),
+ exit(normal);
+ [_,_,$\n|_] ->
+ yaws_log:errlog("Bad header ~p, it contains"
+ " '\\r' or '\\n' at end ",
+ [lists:flatten(H)]),
+ exit(normal);
+ _ ->
+ ok
+ end
+ end, Hs).
+
+
+check_headers([$\r, $\n |Tail], Last) when Tail /= [] ->
+ case lists:member(hd(Tail), [$\r, $\n]) of
+ true ->
+ yaws_log:errlog("Bad header ~p, it contains"
+ " '\\r' or '\\n' at end ", [lists:reverse(Last)]),
+ exit(normal);
+ _ ->
+ check_headers(Tail, [])
+ end;
+
+check_headers([H|T], Last) ->
+ check_headers(T, [H|Last]);
+check_headers([], _) ->
+ ok.
+
+
View
46 src/yaws_server.erl
@@ -204,6 +204,7 @@ init2(Gconf, Sconfs, RunMod, FirstTime) ->
_ ->
false
end,
+ lists:foreach(fun(M) -> runmod(M) end, Gconf#gconf.runmods),
%% start the individual server processes
L = lists:map(
@@ -585,7 +586,9 @@ aloop(CliSock, GS, Num) when GS#gs.ssl == nossl ->
continue ->
aloop(CliSock, GS, Num+1);
done ->
- {ok, Num+1}
+ {ok, Num+1};
+ {page, Page} ->
+ nyi
end
end;
@@ -1516,45 +1519,6 @@ redirect_code(A) ->
{1,0} -> 302;
_ -> 303
end.
-
-check_headers(L) ->
- Hs = string:tokens(lists:flatten(L), "\r\n"),
- io:format("XX ~p~n", [Hs]),
- lists:foreach(
- fun(H) ->
- case lists:reverse(H) of
- [_,_,$\r|_] ->
- yaws_log:errlog("Bad header ~p, it contains"
- " '\\r' or '\\n' at end ",
- [lists:flatten(H)]),
- exit(normal);
- [_,_,$\n|_] ->
- yaws_log:errlog("Bad header ~p, it contains"
- " '\\r' or '\\n' at end ",
- [lists:flatten(H)]),
- exit(normal);
- _ ->
- ok
- end
- end, Hs).
-
-
-check_headers([$\r, $\n |Tail], Last) when Tail /= [] ->
- case lists:member(hd(Tail), [$\r, $\n]) of
- true ->
- yaws_log:errlog("Bad header ~p, it contains"
- " '\\r' or '\\n' at end ", [lists:reverse(Last)]),
- exit(normal);
- _ ->
- check_headers(Tail, [])
- end;
-
-check_headers([H|T], Last) ->
- check_headers(T, [H|Last]);
-check_headers([], _) ->
- ok.
-
-
deliver_accumulated(DCC, Sock, GC, SC) ->
Code = case get(status_code) of
undefined -> 200;
@@ -1566,7 +1530,7 @@ deliver_accumulated(DCC, Sock, GC, SC) ->
if
GC#gconf.debug == true ->
- check_headers(lists:flatten(Headers), []);
+ yaws_debug:check_headers(lists:flatten(Headers), []);
true ->
ok
end,
Please sign in to comment.
Something went wrong with that request. Please try again.