You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nico Coetzee <ni...@gmail.com> on 2010/09/27 11:27:33 UTC

All responses are 200 (server error)

Hi - don't know if anybody else have come across this.

I have a mod_perl instance that produces output just as it should (checked
in the logs and I even written the output to file just to have an extra
check).

The tcpdump also show everything is ok.

BUT

The content has the following HTML appended at the end:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 webmaster@host.example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at webdavtest Port 81</address>
</body></html>

So, I've enabled "debug" level logging everywhere and even enabled
diagnostics in the mod_perl script. Nothing strange shows up anywhere.

I even tried to change the return code with return Apache2::Const::XXX (XXX
could be anything) but the return code is ALWAYS 200 with the above HTML
appended to what ever output is sent to the browser.

I also noted that the content length header is correct for the content sent
to the browser and does not include the additional HTML above, but it still
confuses the browser.

Any ideas?

Environment:

CentOS 5.5 OS with the following packages:

* httpd-2.2.3-43.el5.centos.3
* mod_perl-2.0.4-6.el5

In my config I have the following enabled:

* LogLevel debug
* PerlWarn On

Thanks

Nico

Re: All responses are 200 (server error)

Posted by "William A. Rowe Jr." <wm...@gmail.com>.
On 9/27/2010 6:09 AM, Peter Janovsky wrote:
> Are you returning the value of 200 within a module you've written?  I encountered a
> similar issue within a C module specific to valid requests. It was resolved by returning
> the internal constant OK. 

This is a generalized issue of serving ErrorDocuments; if they have a Status/
result code update (such as a backend proxy response or a cgi response), that
will override the original error code.  c.f.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49996

So it is not strictly a bug, but you certainly aren't the first to be frustrated
by the behavior; look to the manner you handle ErrorDocuments with, first.

Re: Fwd: All responses are 200 (server error)

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 9/28/2010 1:32 AM, Nico Coetzee wrote:
> and... it works now !!

I'd hit the same bug from CGI some half-decade ago, sorry I didn't
see where the problem was in the first place :(

Re: Fwd: All responses are 200 (server error)

Posted by Nico Coetzee <ni...@gmail.com>.
and... it works now !!



On Tue, Sep 28, 2010 at 8:30 AM, Nico Coetzee <ni...@gmail.com> wrote:

> $r->status("400");
> $r->status_line("400 Error Baby");
>
> Produces: "HTTP/1.1 400 Error Baby"
>
> And
>
> $r->status("207");
> $r->status_line("207 Multi-Status");
>
> Produces: "HTTP/1.1 207 Multi-Status"
>
> So, I recon I will try this now in the main app.
>
> Thanks :-)
>
>
>
> On Tue, Sep 28, 2010 at 8:26 AM, William A. Rowe Jr. <wr...@rowe-clan.net>wrote:
>
>> On 9/28/2010 12:25 AM, Nico Coetzee wrote:
>> > The status 400 (with $r->status_line) produces the same result "HTTP/1.1
>> 200 OK" and with
>> > ($r->status) is creates a "HTTP/1.1 400 Bad Request" (the custom string
>> gets lost)
>> >
>> > The $r->status with a code of 499 produces a "HTTP/1.1 400 Bad Request"
>>
>> Sort of confirms my theory.
>>
>> Set status to 400 and set status_line to 400 Custom Message, see what
>> happens?
>>
>> I suspect that 499 simply isn't allowed, which is wrong, but the current
>> behavior none the less.
>>
>
>

Re: Fwd: All responses are 200 (server error)

Posted by Nico Coetzee <ni...@gmail.com>.
$r->status("400");
$r->status_line("400 Error Baby");

Produces: "HTTP/1.1 400 Error Baby"

And

$r->status("207");
$r->status_line("207 Multi-Status");

Produces: "HTTP/1.1 207 Multi-Status"

So, I recon I will try this now in the main app.

Thanks :-)



On Tue, Sep 28, 2010 at 8:26 AM, William A. Rowe Jr. <wr...@rowe-clan.net>wrote:

> On 9/28/2010 12:25 AM, Nico Coetzee wrote:
> > The status 400 (with $r->status_line) produces the same result "HTTP/1.1
> 200 OK" and with
> > ($r->status) is creates a "HTTP/1.1 400 Bad Request" (the custom string
> gets lost)
> >
> > The $r->status with a code of 499 produces a "HTTP/1.1 400 Bad Request"
>
> Sort of confirms my theory.
>
> Set status to 400 and set status_line to 400 Custom Message, see what
> happens?
>
> I suspect that 499 simply isn't allowed, which is wrong, but the current
> behavior none the less.
>

Re: Fwd: All responses are 200 (server error)

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 9/28/2010 12:25 AM, Nico Coetzee wrote:
> The status 400 (with $r->status_line) produces the same result "HTTP/1.1 200 OK" and with
> ($r->status) is creates a "HTTP/1.1 400 Bad Request" (the custom string gets lost)
> 
> The $r->status with a code of 499 produces a "HTTP/1.1 400 Bad Request"

Sort of confirms my theory.

Set status to 400 and set status_line to 400 Custom Message, see what happens?

I suspect that 499 simply isn't allowed, which is wrong, but the current
behavior none the less.

Re: Fwd: All responses are 200 (server error)

Posted by Nico Coetzee <ni...@gmail.com>.
The status 400 (with $r->status_line) produces the same result "HTTP/1.1 200
OK" and with ($r->status) is creates a "HTTP/1.1 400 Bad Request" (the
custom string gets lost)

The $r->status with a code of 499 produces a "HTTP/1.1 400 Bad Request"



On Tue, Sep 28, 2010 at 6:31 AM, William A. Rowe Jr. <wr...@rowe-clan.net>wrote:

> Two thoughts...
>
> try status 400 (might be special handling for 4xx unknown)
>
> try r->status instead of/in addition to just r->status_line?
>

Re: Fwd: All responses are 200 (server error)

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
Two thoughts...

try status 400 (might be special handling for 4xx unknown)

try r->status instead of/in addition to just r->status_line?

Fwd: All responses are 200 (server error)

Posted by Nico Coetzee <ni...@gmail.com>.
Oops - seems I didn't include the group on my reply ....

FYI


Here is another test I did (simpler)

-------------------- Apache Config --------------------

PerlModule FNBC::test_statusline
PerlWarn On

<Location /test1>
   SetHandler perl-script
   PerlResponseHandler FNBC::test_statusline
</Location>

-------------------- test_statusline.pm --------------------

package FNBC::test_statusline;
use strict;
use warnings;
use Apache2::Access ();
use Apache2::RequestUtil ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw( OK );

sub handler {
   my $r = shift;
   $r->status_line("499 We have been FooBared");
   $r->err_headers_out->add( 'X-Testing' => 'True' );
   $r->content_type( "text/html" );
   my $body = "<html><head><title>Testing</title></head><body><h3>It really
does work...</h3></body></html>";
   $r->set_content_length( length( $body ) );
   $r->print( $body );
   return Apache2::Const::OK;
}
1;

-------------------- Trace --------------------

GET /test1/sdjakgd HTTP/1.1
Host: webdavtest:81
User-Agent: Links (2.2; Linux 2.6.32-24-generic x86_64; 210x65)
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Charset: us-ascii, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4,
ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10,
ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, windows-1250,
windows-1251, windows-1252, windows-1256, windows-1257, cp437, cp737, cp850,
cp852, cp866, x-cp866-u, x-mac, x-mac-ce, x-kam-cs, koi8-r, koi8-u, koi8-ru,
TCVN-5712, VISCII, utf-8
Accept-Language: en, *;q=0.1
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Tue, 28 Sep 2010 06:06:13 GMT
Server: Apache/2.2.3 (CentOS)
X-Testing: True
Content-Length: 92
Connection: close
Content-Type: text/html; charset=UTF-8

<html><head><title>Testing</title></head><body><h3>It really does
work...</h3></body></html>


I really would like to know why I can not set the status line.... I followed
the example from
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_status_line_

Thanks

Nico

Re: All responses are 200 (server error)

Posted by Peter Janovsky <pe...@yahoo.com>.
Are you returning the value of 200 within a module you've written?  I encountered a similar issue within a C module specific to valid requests. It was resolved by returning the internal constant OK. 



On Sep 27, 2010, at 5:27, Nico Coetzee <ni...@gmail.com> wrote:

> Hi - don't know if anybody else have come across this.
> 
> I have a mod_perl instance that produces output just as it should (checked in the logs and I even written the output to file just to have an extra check).
> 
> The tcpdump also show everything is ok.
> 
> BUT
> 
> The content has the following HTML appended at the end:
> 
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <html><head>
> <title>200 OK</title>
> </head><body>
> <h1>OK</h1>
> <p>The server encountered an internal error or
> misconfiguration and was unable to complete
> your request.</p>
> <p>Please contact the server administrator,
>  webmaster@host.example.com and inform them of the time the error occurred,
> and anything you might have done that may have
> caused the error.</p>
> <p>More information about this error may be available
> in the server error log.</p>
> <hr>
> <address>Apache/2.2.3 (CentOS) Server at webdavtest Port 81</address>
> </body></html>
> 
> So, I've enabled "debug" level logging everywhere and even enabled diagnostics in the mod_perl script. Nothing strange shows up anywhere.
> 
> I even tried to change the return code with return Apache2::Const::XXX (XXX could be anything) but the return code is ALWAYS 200 with the above HTML appended to what ever output is sent to the browser.
> 
> I also noted that the content length header is correct for the content sent to the browser and does not include the additional HTML above, but it still confuses the browser.
> 
> Any ideas?
> 
> Environment:
> 
> CentOS 5.5 OS with the following packages:
> 
> * httpd-2.2.3-43.el5.centos.3
> * mod_perl-2.0.4-6.el5
> 
> In my config I have the following enabled:
> 
> * LogLevel debug
> * PerlWarn On
> 
> Thanks
> 
> Nico