in reply to How to close connection to browser

I know you mentioned that you are using perl/cgi, but if you are running this under mod_perl, then you can use the mod_perl hooks to register a cleanup handler to do your post request processing. This way Apache will close the connection for you , and then afterwards execute your cleanup handler for you.

If you are using the mod_perl Apache::Registry module to run your cgi/perl script, then you could add something like this to your code:

my $r = Apache->request(); my $sub = sub { # Do your post request processing here }; $r->register_cleanup($sub);

Of course, your code will be dependant on mod_perl at this point and it won't run as a plain old CGI anymore, but I thought it was worth noting as an option.