This problem may be more of an Apache problem but I'm not sure. I hope this is not inappropriate to post this here.
I have a CGI script running on Perl/Apache/Linux that receives a GET request from another server that simply needs to respond with 200 OK or 500 HTTP Header if there is an error.
The system that is calling this script only waits about 10 -20 seconds (not changable). The problem I have is that I need to do some heavyweight processing.
What I want to do is simply tell the client 200 OK "go away now" as the server calling our script would not recognize any other response or data anyway.
The problem is that the client is still hanging around until the script is completed.
I have disabled buffering and tried using the script as an
nph script with no luck. The only way I can force the client to leave is by close(STDOUT), this feels like a big hack to me and I'm sure it will cause a problem at some point.
Forking is not really an option either. I tried copying STDOUT, printing the header and closing STDOUT and restoring as follows with no luck,
#!/usr/bin/perl
# @@@ THIS DOESN'T WORK @@@
require 5.001;
$|=1;
my $query = new CGI;
open (OLDOUT, ">&STDOUT") or die "Couldn't dupe STDOUT!\n";
print $query->header(-status=>'200 OK'),"\n";
close(STDOUT);
open (STDOUT,">&OLDOUT") or die "Couldn't restore STDOUT!\n";
close(OLDOUT);
sleep(20);
print "GO AWAY!;
The result is that the calling server will get the message "GO AWAY"
#!/usr/bin/perl
# @@@ THIS DOES @@@
require 5.001;
$|=1;
my $query = new CGI;
print $query->header(-status=>'200 OK'),"\n";
close(STDOUT);
sleep(20);
print "GO AWAY!;
The calling server will terminate immediatelly after the 200 OK.
Anyone else here ever have a similar problem or a solution for a more elegant fix?
Thanks.