[erlang-questions] mod_esi should return 400 status for missing function

Paul Fisher <>
Fri May 9 20:38:29 CEST 2008


If a Module/Function request matching an erl_script_alias registration
does not exist as a function in the module registered, the current
implementation returns a "500 Internal Server Error", rather than a more
appropriate "400 Bad Request".

Here is a patch that does this:

--- inets/src/http_server/mod_esi.erl.orig      2008-05-09 13:09:07.000000000 -0500
+++ inets/src/http_server/mod_esi.erl   2008-05-09 13:13:52.000000000 -0500
@@ -287,6 +287,9 @@
 %% before anythig is sent back to the client.
 erl_scheme_webpage_whole(Module, Function, Env, Input, ModData) ->
     case (catch Module:Function(Env, Input)) of
+       {'EXIT',{undef, _}} ->
+           {proceed, [{status, {400, ModData#mod.request_uri, "Bad Request"}}
+                      | ModData#mod.data]};
        {'EXIT',Reason} ->
            {proceed, [{status, {500, none, Reason}} |
                       ModData#mod.data]};


-- 
paul




More information about the erlang-questions mailing list