CGI::Carp die with status

B

bernd

Hi,

Has anyone experience with dying from CGI::Carp with a status?
Using LWP one can catch status with:

$response = $ua->request($req);
$content = $response->content;
if ($response->is_success) {
print $content;
} else {
print $response->status_line;
}

However, when the script "dies" with CGI::Carp the exit status is "200
OK".
I'd rather have a status that is not "OK" and not scan the returned
$content for "Software error".

Has someone been able to do this?

Bernd
 
S

smallpond

Hi,

Has anyone experience with dying from CGI::Carp with a status?
Using LWP one can catch status with:

$response = $ua->request($req);
$content = $response->content;
if ($response->is_success) {
print $content;} else {

print $response->status_line;

}

However, when the script "dies" with CGI::Carp the exit status is "200
OK".
I'd rather have a status that is not "OK" and not scan the returned
$content for "Software error".

Has someone been able to do this?

Bernd


HTTP status is set by the -status value in the header. If the cgi is
not checking for errors and exits without setting status you will get
the default. Sounds like it is doing fatalsToBrowser if the error
is showing up in the content. It will also be in the httpd error log
on the server.

You need to post the cgi if you want help fixing it.
--S
 
J

J. Gleixner

bernd said:
Hi,

Has anyone experience with dying from CGI::Carp with a status?
Using LWP one can catch status with:

$response = $ua->request($req);
$content = $response->content;
if ($response->is_success) {
print $content;
} else {
print $response->status_line;
}

However, when the script "dies" with CGI::Carp the exit status is "200
OK".
I'd rather have a status that is not "OK" and not scan the returned
$content for "Software error".

Has someone been able to do this?

Where is "CGI::Carp" being used in your example code? How the
heck is anyone going to be able to help if you don't show exactly
what you're trying?

Show a short example that uses CGI::Carp and produces the error.
 
B

bernd

Hi,

Sorry for not being clear.
A simple CGI example script is:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
die "Some error occured...\n";

I would like the status header not to print 200 OK, but e.g.
status 500, server error.

Usually one can set the status, but I do not know how to set the
status header when the script dies with fatalsToBrowser as above.

Bernd
 
X

xhoster

bernd said:
Hi,

Sorry for not being clear.
A simple CGI example script is:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
die "Some error occured...\n";

I would like the status header not to print 200 OK, but e.g.
status 500, server error.

Usually one can set the status, but I do not know how to set the
status header when the script dies with fatalsToBrowser as above.

Use set_die_handler instead. That is why it is there--to give you more
control than fatalsToBrowser does.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
O

Owen

Hi,

Has anyone experience with dying from CGI::Carp with a status?
Using LWP one can catch status with:

$response = $ua->request($req);
$content = $response->content;
if ($response->is_success) {
print $content;} else {

print $response->status_line;

}

However, when the script "dies" with CGI::Carp the exit status is "200
OK".
I'd rather have a status that is not "OK" and not scan the returned
$content for "Software error".

Has someone been able to do this?

Bernd




Would

use CGI::Carp qw(fatalsToBrowser set_message);

meet your need?


Owen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top