[Haskell-cafe] Re: Network.CGI and error handling

Ketil Malde ketil at malde.org
Thu May 22 17:07:31 EDT 2008


Since Björn Bringert suggested (on IRC) the problem could be due to
laziness, and that I should force the result string before giving it
to "output", I've been playing around a bit.  (The program is somewhat
more involved than the short test I provided earlier, but available on
request). 

Without strictness, I get a blank page, and an message in the
error_log:

  [Thu May 22 22:00:15 2008] [error] [client 10.1.4.222] snp.cgi: Prelude.last: empty list, referer: http://gadidae/snp.c
gi

This is okay, but I would still like some output to the user.  With
strict evaluation of output's argument, I instead get a web page that
appears to hang (showing a hourglass cursor and animated toolbar
icon).  In the log, I find:

  [Thu May 22 22:22:44 2008] [error] [client 10.1.4.222] Premature end of script headers: snp-strict.cgi, referer: http://gadidae/snp-strict.cgi
  [Thu May 22 22:26:32 2008] [error] [client 10.1.4.222] Premature end of script headers: snp-strict.cgi, referer: http://gadidae/snp-strict.cgi
  [Thu May 22 22:27:44 2008] [error] [client 10.1.4.222] (500,"Internal Server Error",["Prelude.last: empty list"]), referer: http://gadidae/snp-strict.cgi
  [Thu May 22 22:31:32 2008] [error] [client 10.1.4.222] (500,"Internal Server Error",["Prelude.last: empty list"]), referer: http://gadidae/snp-strict.cgi

I interpret this as the system putting things on hold for about ten minutes
before terminating my script, and for some reason, the intended error
document is put in the log instead of being returned to the
browser/client. This is just weird.

(I do actually get a 500 from the server, but that just talks about
"premature end of script headers", and not about the actual bug in my
program, so I belive this is just what apache says when terminating a
runaway cgi)

Network.CGI does look like an established library, certainly the
documentation I find is very good and complete, and the interface is
concise, logical, and to the point.  It seems a shame that it doesn't
work.  Does anybody else have it working?  I'd be very happy to hear
about it, even if it just works for you.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list