View previous topic :: View next topic |
Author |
Message |
lmz -
Joined: 28 Oct 2006 Posts: 4
|
Posted: Sat Oct 28, 2006 3:25 pm Post subject: Perl ISAPI extra newline in header? |
|
|
I have installed Abyss Web Server X1 v2.3.2 and ActivePerl (5.8.8 build 817) with the ISAPI DLL. I am currently trying to run Perl scripts using the ISAPI interface. Here is the relevant bit from abyss.conf (CGI/ISAPI, type is Perl ISAPI):
Code: |
<interpreter>
<ext>
pl
</ext>
<interface>
0
</interface>
<file>
Z:\pkg\Perl\bin\perlis.dll
</file>
<checkexists>
yes
</checkexists>
<type>
2
</type>
<updatepaths>
no
</updatepaths>
</interpreter>
|
It seems to insert extra newlines before the script output so the script cannot add the Content-Type header. I tried the following two scripts:
plain.pl:
Code: |
print "Content-Type: text/plain\r\n\r\nHello!";
|
test.pl (taking a little from the CGI perldoc)
Code: |
use CGI qw /:standard/;
print header, start_html('test'), h1('Hello');
|
This is what I get when trying to access the files from the command line (using the LWP "get" utility)
Code: |
Z:\>get -ue http://localhost/cgi-bin/plain.pl
GET http://localhost/cgi-bin/plain.pl
Connection: Close
Date: Sat, 28 Oct 2006 14:10:50 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2 Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Client-Date: Sat, 28 Oct 2006 14:10:50 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Content-Type: text/plain
Hello!
Z:\>get -ue http://localhost/cgi-bin/test.pl
GET http://localhost/cgi-bin/test.pl
Connection: Close
Date: Sat, 28 Oct 2006 14:12:15 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2 Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Client-Date: Sat, 28 Oct 2006 14:12:15 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Hello</h1>
|
When I test it in the browser, the "Content-Type" header shows up in the browser display.
I have turned on logging for the ISAPI and this is the contents:
Code: |
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 New request
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 Prefetch-ReadClient() = ""
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 ServerSupportFunction(dwHSERequest=HSE_REQ_MAP_URL_TO_PATH, lpvBuffer="")
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 GetServerVariable(szVariableName="SCRIPT_NAME")="/cgi-bin/plain.pl"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 GetServerVariable(szVariableName="SERVER_PROTOCOL")="HTTP/1.1"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 WriteClient(Buffer="HTTP/1.1 200 OK
", dwSize=17, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 WriteClient(Buffer="Date: Sat, 28 Oct 2006 14:10:50 GMT
", dwSize=37, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 GetServerVariable(szVariableName="SERVER_SOFTWARE")="Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 WriteClient(Buffer="Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
", dwSize=47, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 WriteClient(Buffer="Content-Type: text/plain
Hello!", dwSize=34, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/plain.pl Request #0 HttpExtensionProc() = HSE_STATUS_SUCCESS (1) / ecb.dwHttpStatusCode = 200
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 New request
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 Prefetch-ReadClient() = ""
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 ServerSupportFunction(dwHSERequest=HSE_REQ_MAP_URL_TO_PATH, lpvBuffer="")
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="SCRIPT_NAME")="/cgi-bin/test.pl"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="SERVER_SOFTWARE")="Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="GATEWAY_INTERFACE")="CGI/1.1"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="SERVER_PROTOCOL")="HTTP/1.1"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="SERVER_PROTOCOL")="HTTP/1.1"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="HTTP/1.1 200 OK
", dwSize=17, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="Date: Sat, 28 Oct 2006 14:12:15 GMT
", dwSize=37, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 GetServerVariable(szVariableName="SERVER_SOFTWARE")="Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2"
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
", dwSize=47, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="Content-Type: text/html; charset=ISO-8859-1
", dwSize=47, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
", dwSize=316, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 WriteClient(Buffer="<h1>Hello</h1>", dwSize=14, dwSync=0)
Module: Z:\pkg\Perl\bin\perlis.dll URI: /cgi-bin/test.pl Request #1 HttpExtensionProc() = HSE_STATUS_SUCCESS (1) / ecb.dwHttpStatusCode = 200
|
I think this shows that there are two newlines sent after the "Server:..." header. I have tested these scripts with CGI and they work fine. Is this a problem in my configuration, in Abyss or a in the ActivePerl ISAPI DLL?
Thanks |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sat Oct 28, 2006 9:29 pm Post subject: |
|
|
It's normal for the extra two lines before the actual HTML output is sent. You
will notice this from all header output scripts.
The real problem is that you're using "\r\n" in the header lines. You need to
use, only the "\n" characters. Example: print "Content-Type: text/html\n\n";
For a full header output:
Code: | print "HTTP/1.1 200 OK\n";
print "Content-Length: 13\n";
print "Content-Type: text/html\n\n";
print "Hello, World!";
|
Note: The last line always requires two "\n" characters. |
|
Back to top |
|
|
lmz -
Joined: 28 Oct 2006 Posts: 4
|
Posted: Sun Oct 29, 2006 2:43 pm Post subject: |
|
|
TRUSTAbyss wrote: |
Code: | print "HTTP/1.1 200 OK\n";
print "Content-Length: 13\n";
print "Content-Type: text/html\n\n";
print "Hello, World!";
|
|
That actually works, but I'd rather not print my HTTP headers myself.
It seems that I need to force the CGI module to do NPH. There is a check to make sure NPH is enabled automatically if it's running under IIS but probably they need to add another check for Abyss... The code below works:
Code: |
use CGI qw( -nph );
my $cgi = new CGI;
print $cgi->header(),
$cgi->start_html('hello world'),
$cgi->h1('hello world'),
$cgi->end_html();
|
Thanks for the help :) |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sun Oct 29, 2006 2:52 pm Post subject: |
|
|
lmz wrote: | It seems that I need to force the CGI module to do NPH. There is a check to make sure NPH is enabled automatically if it's running under IIS but probably they need to add another check for Abyss... The code below works: |
Abyss Web Server is smart enough to detect if you're sending an NPH output or not. So there is no need for such a setting as everything is handled automatically.
As you noticed both scripts (NPH and not NPH) worked fine. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
lmz -
Joined: 28 Oct 2006 Posts: 4
|
Posted: Mon Oct 30, 2006 4:43 pm Post subject: |
|
|
aprelium wrote: | lmz wrote: | It seems that I need to force the CGI module to do NPH. There is a check to make sure NPH is enabled automatically if it's running under IIS but probably they need to add another check for Abyss... The code below works: |
Abyss Web Server is smart enough to detect if you're sending an NPH output or not. So there is no need for such a setting as everything is handled automatically.
As you noticed both scripts (NPH and not NPH) worked fine. |
Well, I don't even know what NPH is or how Abyss detects it, but I know that this code:
Code: |
use CGI qw( -nph );
my $cgi = new CGI;
print $cgi->header(),
$cgi->start_html('hello world'),
$cgi->h1('hello world'),
$cgi->end_html();
|
works fine, and this code (note the commented out nph param):
Code: |
use CGI ; # qw( -nph );
my $cgi = new CGI;
print $cgi->header(),
$cgi->start_html('hello world'),
$cgi->h1('hello world'),
$cgi->end_html();
|
displays a Content-Type header in the response body (with configuration like in my first post). |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Oct 31, 2006 10:29 am Post subject: |
|
|
lmz,
NPH means Non-parsed headers. This is when the script sends headers to the server without using the CGI spec and asks the server to not preprocess them and to forward them as they are to the client directly.
In the second script it seems that Perl ISAPI is messing with the NPH output. Could you please set temporarily the Perl interpreter to use perl.exe instead of PerlIS.dll and retest your second script? Is it working fine? _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
lmz -
Joined: 28 Oct 2006 Posts: 4
|
Posted: Thu Nov 02, 2006 10:08 am Post subject: |
|
|
OK, so I have associated *.pl with Perl ISAPI and *.pcgi with Perl CGI.
this is nph.{pl,pcgi} :
Code: |
use CGI qw( -nph );
my $cgi = new CGI;
print $cgi->header(),
$cgi->start_html('hello world'),
$cgi->h1('hello world'),
$cgi->end_html();
|
and this is nonph.{pl,pcgi}
Code: |
use CGI ; #qw( -nph );
my $cgi = new CGI;
print $cgi->header(),
$cgi->start_html('hello world'),
$cgi->h1('hello world'),
$cgi->end_html();
|
and the results:
Code: |
Z:\cgi-bin>GET -ue http://localhost/cgi-bin/nph.pl
GET http://localhost/cgi-bin/nph.pl
Connection: Close
Date: Thu, 02 Nov 2006 09:03:11 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2 Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/html; charset=iso-8859-1
Client-Date: Thu, 02 Nov 2006 09:03:12 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Title: hello world
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>hello world</h1>
</body>
</html>
Z:\cgi-bin>GET -ue http://localhost/cgi-bin/nph.pcgi
GET http://localhost/cgi-bin/nph.pcgi
Date: Thu, 02 Nov 2006 09:03:15 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/html; charset=iso-8859-1
Client-Date: Thu, 02 Nov 2006 09:03:15 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Title: hello world
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>hello world</h1>
</body>
</html>
Z:\cgi-bin>GET -ue http://localhost/cgi-bin/nonph.pl
GET http://localhost/cgi-bin/nonph.pl
Connection: Close
Date: Thu, 02 Nov 2006 09:03:37 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2 Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Client-Date: Thu, 02 Nov 2006 09:03:38 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>hello world</h1>
</body>
</html>
Z:\cgi-bin>GET -ue http://localhost/cgi-bin/nonph.pcgi
GET http://localhost/cgi-bin/nonph.pcgi
Connection: Close
Date: Thu, 02 Nov 2006 09:03:40 GMT
Server: Abyss/2.3.2-X1-Win32 AbyssLib/2.3.2
Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/html; charset=iso-8859-1
Client-Date: Thu, 02 Nov 2006 09:03:40 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Title: hello world
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>hello world</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>hello world</h1>
</body>
</html>
|
In a web browser, all of them display fine except the nonph.pl script which displays a content-type header in the document body. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Nov 02, 2006 11:12 am Post subject: |
|
|
lmz,
Thank you for the detailed information you have provided. We'll check the Perl ISAPI again with your script to determine why it is sending the Content-type header in the body.
FYI, the ActivePerl ISAPI mode has been created to provide several workarounds and to fix the broken behavior of this ISAPI which is not fully conforming to the standard. We did our best to test it with popular Perl scripts but as you have shown with your simple test, there are still situations which are not correctly handled. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|