http://qs1969.pair.com?node_id=11111940

knox has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Your wisdom once again is appreciated. I've been testing some FCGI scripts, I've managed to get CGI::Fast working, but I'd like to get FCGI working. Unfortunately, I haven't be able to find good working examples. I'd like to see an example of FCGI return $ENV vars, similar to the CGI::Fast used in the Apache example: https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html. The code posted below is just me trying to get something to work, it is giving an internal server error. I've posted this is from my error log:

[Mon Jan 27 19:44:02.915926 2020] [fcgid:warn] [pid 20681] (104)Connec +tion reset by peer: [client xx.xxx.xxx.xxx:xxxxx] mod_fcgid: error re +ading data from FastCGI server [Mon Jan 27 19:44:02.915973 2020] [core:error] [pid 20681] [client xx. +xxx.xxx.xxx:xxxxx] End of script output before headers: test.fcgi <code> <code> #!/usr/bin/perl use FCGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use Encode; #use CGI::Fast; #the CGI:Fast example from https://httpd.apache.org/mod_fcgid/mod/mod_ +fcgid.html is working; my FCGI example is not. my $count = 0; my $request = FCGI::Request(); while($request->Accept() >= 0) { $body = "Content-type:text/html; charset=utf-8\r\n\r\n"; $body .= '<html><head><meta http-equiv="Content-Type" content="te +xt/html; charset=utf-8" /></head><body>'; $body .= '<h1>Woohoooo!</h1>': $body .= '</body></html>'; $body .= '</body></html>'; $body = encode_utf8($body); print $body; }

Aside from that, I have a very basic question with FastCGI - as it keeps a persistent connection, whats the best way to temporarily test it? I am new to FastCGI, it is compelling, but I don't know the vernacular to describe it well (yet). Let me know if the above doesn't make sense. Secondly, is there a way to get more descriptive error messages than the ones that come out of apache.log?

And yes! I will look into frameworks like Plack/Dancer - but before I do, I'd like to get grasp of how FCGI works before I put a layer on top of it.