From: Christopher F. <chr...@ca...> - 2014-06-25 09:57:35
|
On 25/06/2014 01:01, Ian wrote: > In the course of to remember if I'd made any other changes I've > discovered it's got something to do with fcgi. > > If I use plain cgi, the mod works OK, but if I use fcgi it hangs (and > eventually times out). > > Doesn't help me solve the problem though :-( > Hi, To do FCGI calls, you should use yaws_cgi:call_fcgi_responder/2. But in your case, you need to modify the #arg record passed as argument to point on the good script. Here is your out404 function, rewritten to handle CGI and FCGI calls: out404(Arg, _GC, SC) -> FullPath = filename:join(yaws_api:arg_docroot(Arg), "err.php"), case yaws:sconf_php_handler(SC) of {fcgi, {Host, Port}} -> yaws_cgi:call_fcgi_responder( Arg#arg{fullpath=FullPath}, [{app_server_host, Host}, {app_server_port, Port}] ); {cgi, Bin} -> yaws_cgi:call_cgi(Arg, Bin, FullPath) end. But, yaws_cgi is not really public. A better way to do what you want is to use the internal redirections: out404(_Arg, _GC, _SC) -> {page, "/err.php"}. Note: Yesterday, I found a bug with internal redirections. The original request (#arg.orig_req) is lost. In CGI/FCGI calls, this field is used to set REQUEST_URI variable ($_SERVER["REQUEST_URI"] in php). I will fix this very soon. But, in the meantime, a workaround could be to add it in the query string: get_request_uri(#arg{req=Req, orig_req=undefined}) -> {abs_path, RequestUri} = Req#http_request.path, RequestUri; get_request_uri(#arg{orig_req=OrigReq}) -> {abs_path, RequestUri} = OrigReq#http_request.path, RequestUri. out404(Arg, _GC, _SC) -> Uri = yaws_api:url_encode(get_request_uri(Arg)), {page, "/err.php?uri="++Uri}. Hope that helps :) -- Christopher |