From: rdoz...@hotmail.com
To: users@httpd.apache.org
Date: Mon, 9 Jul 2012 17:04:07 +0200
Subject: [users@httpd] apache adds extra HTML to an error page


hello list,

I am trying to migrate a perl script that acts as a webserver from solaris to 
linux (red hat). The script is run using apache (httpd) and mod_perl.

It nearly does what it is supposed to, exept for the error pages.
When an error occurs and the script can not fulfill the request, it sends a 
small error page to the user, containing two p elements, together with status 
500.

This used to work OK, but on the new machine, apache decides to add extra text 
to the page. The receiving application sees a page that does not conform to the 
specification and thinks it is not an error page. This results in various 
problems.

I have not the slightest idea in what direction I have to search. Is it an 
apache configuration issue or maybe a perl library issue? I really don't know.
Can you guys give me some clue?

This is the perl code that makes the error page:

    print $cgi->header (  -status => '500 NOT OK',

                                        -type   => 'text/html');
    print $cgi->start_html ('agent');
    print $cgi->p ('ERROR');
    print $cgi->p ('error during database lookup');
    print $cgi->end_html ();




I have figured out what was giving me the unwanted results. Maybe someone with 
similar problems finds this in the archive sometime....

The problem is the perl-CGI library. When switching to another machine, it 
changed behaviour in a subtle way, causing the problem.
The commands in the code above all print to STDOUT _except for_ the first one, 
the header routine. This does something indeed: the browser does receive the 
stated the status code. However, it is not done via STDOUT. Replacing this 
method call by print statements that make the headerlines, fixed the problem 
for me:

print "Status: 500 NOT OK\n";
print "Content-type: text/html\n";

phew! Glad I found it at last. Thanks a lot to everyone who took the time to 
read my questions and helped me!!!

Ruud
                                                                                
  

Reply via email to