For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > December 2005 > Apache vs Boa error LFLF









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Apache vs Boa error LFLF
Shawn Sharp

2004-09-12, 8:55 pm

I am working on some perl cgi code that works on an apache webserver but
I get the following error when I run it on a boa webserver



[08/Sep/2004:23:41:09 +0000] cgi_header: unable to find LFLF.



I have tried the following change



From:

print "content-type: text/html\n\n";



changed to:



print "content-type: text/html\r\n\r\n";



any ideas.



Has anyone else seen code that works on an apache webserver but not on a
Boa server


Bob Showalter

2004-09-12, 8:55 pm

Shawn Sharp wrote:
> I am working on some perl cgi code that works on an apache webserver
> but I get the following error when I run it on a boa webserver
>
> [08/Sep/2004:23:41:09 +0000] cgi_header: unable to find LFLF.
>
> I have tried the following change
>
> From:
>
> print "content-type: text/html\n\n";
>
> changed to:
>
> print "content-type: text/html\r\n\r\n";
>
> any ideas.


I don't know what Boa is, but the controlling standard is RFC2616
(http://www.faqs.org/rfcs/rfc2616.html), which calls for CRLF as the line
terminator in the message header section. But see also section 19.3,
"Tolerant Applications". apache follows the tolerant applications
recommendations.

This kind of thing is why we recommend you use the CGI module instead of
rolling your own code.

use CGI ':standard';
print header;

For kicks, have a look at the CGI.pm source code ("perldoc -m CGI") and
search for the string "Define the CRLF sequence".

It may be possible that Boa is not RFC-compliant. If you use the CGI
module's header() method and it still doesn't work, I would take it up with
the Boa folks...
matt123

2005-12-14, 12:24 am

I'm know replying to an ancient problem, but I had the same problem with a CGI, written in C. I hope this might help someone who hits this page in a search.

I only wanted my NPH CGI to send one line:

printf("HTTP/1.0 204 No Content\r\n\r\n"); /* Does not work */

My browser kept giving me the "502" error and the Boa error_log told me the "LFLF" missing problem. I scanned the Boa source code and found the header parsing source code to be very straight-forward. The Boa header parsing code was bailing-out alomst immediately with the error.

I figured that the Boa server wasn't receiving anything from the CGI (that was the only way that my simple code wouldn't work). So, I put a fflush(stdout) after the printf() and everything worked fine:

printf("HTTP/1.0 204 No Content\r\n\r\n"); /* This works */
fflush(stdout);

Sorry that I don't know any Perl programming, so this C example is the best I can do :)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com