Forum Moderators: coopster & phranque

Message Too Old, No Replies

NonParsed Headers

         

Brett_Tabke

12:12 am on Sep 6, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What is wrong with this script that I would get a 500 error all the time on any server.

#!/usr/bin/perl
$server_protocol = $ENV{'SERVER_PROTOCOL'};
$server_software = $ENV{'SERVER_SOFTWARE'};
print "$server_protocol 200 OK", "\n";
print "Server: $server_software", "\n";
print "Content-type: text/plain", "\n\n";
print "count from 1 to 50", "\n";
$¦ = 1;
for ($loop=1; $loop <= 50; $loop++) {
print $loop, "\n";
}
print "Done\n";

----
error log shows:
malformed header from script. Bad header=HTTP/1.1 200 OK:

I'm baffled. Got to be something simple-stupid. I used the above script because it is one passed around by Apache and I know it did work at one point.

littleman

1:14 am on Sep 6, 2001 (gmt 0)



I just ran the script 'asis' on Apache/1.3.20 and it worked fine.

What server type are you trying it on?

Brett_Tabke

2:58 am on Sep 6, 2001 (gmt 0)

bobriggs

3:46 am on Sep 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HTTP/1.1 302 Found
Date: Thu, 06 Sep 2001 03:39:21 GMT
Server: Apache/1.3.4 (Unix) FrontPage/4.0.4.3
Location: [webmasterworld.com...]
Transfer-Encoding: chunked
Content-Type: text/html

That's the header I get back (from test.cgi) - which of course goes to the 404 page - with return code 200. Is this the same script or are you working on something else?

Brett_Tabke

5:19 am on Sep 6, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



That's just the redirect after the error Bob. The script dies generating the error mentioned, then the redirect to the 500 Error doc takes over.

mark_roach

12:03 pm on Sep 6, 2001 (gmt 0)

10+ Year Member



Is this it ?

print "Status: $server_protocol 200 OK", "\n";

[added]

Forget that last suggestion.

I still can't quite get the script to work but the info on here might help:

[hoohoo.ncsa.uiuc.edu...]

Script naming conventions

Normally, scripts produce output which is interpreted and sent back to the client. An advantage of this is that the scripts do not need to send a full HTTP/1.0 header for every request.

Some scripts may want to avoid the extra overhead of the server parsing their output, and talk directly to the client. In order to distinguish these scripts from the other scripts, CGI requires that the script name begins with nph- if a script does not want the server to parse its header. In this case, it is the script's responsibility to return a valid HTTP/1.0 (or HTTP/0.9) response to the client.

Now I have renamed the script I get the download prompt, so there still appears to be something not quite right with the headers.

[/added]

Bolotomus

1:35 pm on Sep 6, 2001 (gmt 0)

10+ Year Member



I put this script on my server and got the same error Brett got. Then I realized, "oh what a fool I am" -- I named my script "test.pl"

I renamed it to "nph-test.pl" and then it worked fine.

My guess is, either you have been silly like I was above, or if not that, for some reason on your system $ENV{'SERVER_PROTOCOL'} isn't returning the proper value.

Brett_Tabke

7:38 pm on Sep 6, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



DOH! (told you it was something simple!) I'd completely forgotten that tid bit. Thanks.

twiggy00

2:49 pm on Oct 10, 2001 (gmt 0)



You need to have the line:
print "Content-type:text/html\n\n";
as the first line printed to stdout or the server doesn't kow what you are sending and so the 500 error is returned

littleman

6:44 pm on Oct 10, 2001 (gmt 0)



Twiggy, give it a try as a 'nph' script and see what happens.

twiggy00

8:19 pm on Oct 10, 2001 (gmt 0)



Sorry littleman guess I should pay attention to the topic. First time I've heard of nph scripts. What's the point if you don't mind.

littleman

8:33 pm on Oct 10, 2001 (gmt 0)



Non-Parsed-Header scripts allow you to generate your own header information and pass it directly to the browser. You could use this technique if you want to manipulate date and status code, or if you want to have your script's output unbuffered.

BTW, welcome to wmw.

twiggy00

8:50 pm on Oct 10, 2001 (gmt 0)



Thanks!

Brett_Tabke

6:55 am on Oct 11, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Or if you want to specifically set "cache" headers for AOL.