Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Http Response code

Posted on 2007-08-24 01:21:26 by mohitanchlia

Is there any way we can successfully tell web server to use the error
code that we set in response object. I am doing this below when cgi is
called, expecting web server to send 503 as response code instead of
200:

#!/usr/bin/perl
require HTTP::Response;
require LWP::UserAgent;

$response = HTTP::Response->new(503) ;
$response->header('Content-Type' => 'text/plain');
$response->header('Content-length' => '5');
$response->content("Error");
print $response->as_string;

But, webserver doesn't like it. It's writing invalid cgi header errors
to the logs. How do I change the response codes ?

Report this message

#2: Re: Http Response code

Posted on 2007-08-24 01:48:16 by Jim Gibson

In article <1187911286.776265.279700@x40g2000prg.googlegroups.com>,
<mohitanchlia@gmail.com> wrote:

> Is there any way we can successfully tell web server to use the error
> code that we set in response object. I am doing this below when cgi is
> called, expecting web server to send 503 as response code instead of
> 200:
>
> #!/usr/bin/perl
> require HTTP::Response;
> require LWP::UserAgent;
>
> $response = HTTP::Response->new(503) ;
> $response->header('Content-Type' => 'text/plain');
> $response->header('Content-length' => '5');
> $response->content("Error");
> print $response->as_string;
>
> But, webserver doesn't like it. It's writing invalid cgi header errors
> to the logs. How do I change the response codes ?
>

HTTP::Response (and LWP::UserAgent) are for client-side programs
pretending to be browsers. For CGI, you want to use the CGI module and
return an appropriate header, e.g.

use CGI;
print header('text/html','503 Service unavailable');


See 'perldoc CGI' and search for 'STANDARD HTTP HEADER'.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message

#3: Re: Http Response code

Posted on 2007-08-24 06:01:08 by mohitanchlia

On Aug 23, 4:48 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1187911286.776265.279...@x40g2000prg.googlegroups.com>,
>
>
>
> <mohitanch...@gmail.com> wrote:
> > Is there any way we can successfully tell web server to use the error
> > code that we set in response object. I am doing this below when cgi is
> > called, expecting web server to send 503 as response code instead of
> > 200:
>
> > #!/usr/bin/perl
> > require HTTP::Response;
> > require LWP::UserAgent;
>
> > $response = HTTP::Response->new(503) ;
> > $response->header('Content-Type' => 'text/plain');
> > $response->header('Content-length' => '5');
> > $response->content("Error");
> > print $response->as_string;
>
> > But, webserver doesn't like it. It's writing invalid cgi header errors
> > to the logs. How do I change the response codes ?
>
> HTTP::Response (and LWP::UserAgent) are for client-side programs
> pretending to be browsers. For CGI, you want to use the CGI module and
> return an appropriate header, e.g.
>
> use CGI;
> print header('text/html','503 Service unavailable');
>
> See 'perldoc CGI' and search for 'STANDARD HTTP HEADER'.
>
> --
> Jim Gibson
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com

I read little bit about it and saw there is something called as -
status. So what's the difference between:

print header('text/html','204 No response');

and

print header(-status=>cgi_error);

Both seem to be returning error codes

Report this message

#4: Re: Http Response code

Posted on 2007-08-24 18:47:03 by Jim Gibson

In article <1187928068.424378.215060@i13g2000prf.googlegroups.com>,
<mohitanchlia@gmail.com> wrote:


>
> I read little bit about it and saw there is something called as -
> status. So what's the difference between:
>
> print header('text/html','204 No response');
>
> and
>
> print header(-status=>cgi_error);
>
> Both seem to be returning error codes
>

Yes. In the first case you determine the response. In the second case,
the CGI module is determining the response.

You can also do:

print header(-status=>'204 No response');

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Report this message