aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2010-03-22 12:00:00 +0100
committerBjörn Gustavsson <[email protected]>2010-08-20 08:49:47 +0200
commitb792ebc90dca5c9ba3d75d7f3c56e2295ae5d6f3 (patch)
tree00646a187671eb46e7621b47d5ba0d8a4fcd19bb /lib/inets/src/http_server
parent4b4409332636b70fb22c3bcaf7e0ba5ef1538bf7 (diff)
downloadotp-b792ebc90dca5c9ba3d75d7f3c56e2295ae5d6f3.tar.gz
otp-b792ebc90dca5c9ba3d75d7f3c56e2295ae5d6f3.tar.bz2
otp-b792ebc90dca5c9ba3d75d7f3c56e2295ae5d6f3.zip
inets: Patch 1111
OTP-8508 [httpc] Badly formated error reason for errors occuring during initial connec to a servert. Also, the possible error reasons was not properly documented. OTP-8509 [httpd] Issues with ESI erl_script_timeout. </p> *) The "erl_script_timeout" config option is ducumented as a number of seconds. But when parsing the config, in the new format (not a config file), it was handled as if in number of milliseconds. *) When the erl-script-timeout time was exceeded, the server incorrectly marked the answer as sent, thereby leaving client hanging (with an incomplete answer). This has been changed, so that now the socket will be closed.
Diffstat (limited to 'lib/inets/src/http_server')
-rw-r--r--lib/inets/src/http_server/httpd_conf.erl2
-rw-r--r--lib/inets/src/http_server/mod_esi.erl26
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/inets/src/http_server/httpd_conf.erl b/lib/inets/src/http_server/httpd_conf.erl
index 3e498d1db7..5ca2e47eb5 100644
--- a/lib/inets/src/http_server/httpd_conf.erl
+++ b/lib/inets/src/http_server/httpd_conf.erl
@@ -354,7 +354,7 @@ load("DocumentRoot " ++ DocumentRoot,[]) ->
{ok, Directory} ->
{ok, [], {document_root,string:strip(Directory,right,$/)}};
{error, _} ->
- {error, ?NICE(clean(DocumentRoot)++"is an invalid DocumentRoot")}
+ {error, ?NICE(clean(DocumentRoot)++" is an invalid DocumentRoot")}
end;
load("DefaultType " ++ DefaultType, []) ->
{ok, [], {default_type,clean(DefaultType)}};
diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl
index 484d4b3fb4..cb33544540 100644
--- a/lib/inets/src/http_server/mod_esi.erl
+++ b/lib/inets/src/http_server/mod_esi.erl
@@ -33,6 +33,7 @@
-define(VMODULE,"ESI").
-define(DEFAULT_ERL_TIMEOUT,15000).
+
%%%=========================================================================
%%% API
%%%=========================================================================
@@ -52,6 +53,7 @@ deliver(SessionID, Data) when is_pid(SessionID) ->
deliver(_SessionID, _Data) ->
{error, bad_sessionID}.
+
%%%=========================================================================
%%% CALLBACK API
%%%=========================================================================
@@ -74,6 +76,8 @@ do(ModData) ->
{proceed, ModData#mod.data}
end
end.
+
+
%%--------------------------------------------------------------------------
%% load(Line, Context) -> eof | ok | {ok, NewContext} |
%% {ok, NewContext, Directive} |
@@ -127,6 +131,7 @@ load("ErlScriptNoCache " ++ CacheArg, [])->
" is an invalid ErlScriptNoCache directive")}
end.
+
%%--------------------------------------------------------------------------
%% store(Directive, DirectiveList) -> {ok, NewDirective} |
%% {ok, [NewDirective]} |
@@ -163,16 +168,18 @@ store({eval_script_alias, {Name, Modules}} = Conf, _)
store({erl_script_alias, Value}, _) ->
{error, {wrong_type, {erl_script_alias, Value}}};
-store({erl_script_timeout, Value} = Conf, _)
- when is_integer(Value), Value >= 0 ->
- {ok, Conf};
+store({erl_script_timeout, TimeoutSec}, _)
+ when is_integer(TimeoutSec) andalso (TimeoutSec >= 0) ->
+ {ok, {erl_script_timeout, TimeoutSec * 1000}};
store({erl_script_timeout, Value}, _) ->
{error, {wrong_type, {erl_script_timeout, Value}}};
-store({erl_script_nocache, Value} = Conf, _) when Value == true;
- Value == false ->
+store({erl_script_nocache, Value} = Conf, _)
+ when (Value =:= true) orelse (Value =:= false) ->
{ok, Conf};
store({erl_script_nocache, Value}, _) ->
{error, {wrong_type, {erl_script_nocache, Value}}}.
+
+
%%%========================================================================
%%% Internal functions
%%%========================================================================
@@ -227,7 +234,7 @@ alias_match_str(Alias, eval_script_alias) ->
%%------------------------ Erl mechanism --------------------------------
erl(#mod{method = Method} = ModData, ESIBody, Modules)
- when Method == "GET"; Method == "HEAD"->
+ when (Method =:= "GET") orelse (Method =:= "HEAD") ->
case httpd_util:split(ESIBody,":|%3A|/",2) of
{ok, [ModuleName, FuncAndInput]} ->
case httpd_util:split(FuncAndInput,"[\?/]",2) of
@@ -347,7 +354,7 @@ erl_scheme_webpage_chunk(Mod, Func, Env, Input, ModData) ->
Pid = spawn_link(
fun() ->
case catch Mod:Func(Self, Env, Input) of
- {'EXIT',{undef,_}} ->
+ {'EXIT', {undef,_}} ->
%% Will force fallback on the old API
exit(erl_scheme_webpage_chunk_undefined);
_ ->
@@ -430,11 +437,12 @@ handle_body(Pid, ModData, Body, Timeout, Size, IsDisableChunkedSend) ->
{proceed, [{response, {already_sent, 200, Size}} |
ModData#mod.data]};
{'EXIT', Pid, Reason} when is_pid(Pid) ->
+ httpd_response:send_final_chunk(ModData, IsDisableChunkedSend),
exit({mod_esi_linked_process_died, Pid, Reason})
after Timeout ->
process_flag(trap_exit,false),
- {proceed,[{response, {already_sent, 200, Size}} |
- ModData#mod.data]}
+ httpd_response:send_final_chunk(ModData, IsDisableChunkedSend),
+ exit({mod_esi_linked_process_timeout, Pid})
end.
erl_script_timeout(Db) ->