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

Paul Fisher pfisher@REDACTED
Sat May 10 18:48:10 CEST 2008


On Sat, 2008-05-10 at 08:57 -0500, Paul Fisher wrote:
> The client is not requesting a "known and valid resource", that is for
> the server-side to define, which in the case of mod_esi implementations
> is the functions exported from the module(s) registered.  If a valid
> mod_esi implementation is registered for a resource path, then by
> definition its public methods defined the resource space... since
> nothing else possibly could.

As an example, the Googles gdata API documentation seems to support this
interpretation:

http://code.google.com/apis/gdata/reference.html#http-status-codes

Specifically this bit:

"Passing a standard parameter not understood by a given service results
in a 403 Forbidden response. Passing an unsupported nonstandard
parameter results in a 400 Bad Request response. For information on
other status codes..."

In the mod_esi case we are talking about passing a resource component
(e.g. the Function in the resource names ".../Module:Function" or
".../Module/Function") which is an expected component of the resource
path that is expected by mod_esi structure, but not understood by the
service implementation (i.e. function not defined).  I'm not sure that I
agree with their use of 403, since I have always reserved that for
authentication/access control issues, but fundamentally we are talking
about 4xx series errors.

I stand by my patch with a 404 response code:

--- 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-10 11:46:03.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, {404, ModData#mod.request_uri, "Not found"}}
+                      | ModData#mod.data]};
        {'EXIT',Reason} ->
            {proceed, [{status, {500, none, Reason}} |
                       ModData#mod.data]};



-- 
paul




More information about the erlang-questions mailing list