Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

NPH script stopped working correctly

by ultranerds (Hermit)
on May 15, 2015 at 10:15 UTC ( [id://1126758]=perlquestion: print w/replies, xml ) Need Help??

ultranerds has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've got a bit of an annoying issue! Our script used to work just fine - where it would print out the pages content as it was outputted from the script (using nph headers). However, for the last couple of weeks it just prints out the plain text (not HTML). To test this out, I made 2 scripts:

testing.cgi
nph-testing.cgi

Both with the same code:

#!/usr/bin/perl

$| = 1;
print "Content-Type: text/html\n
\n";

print "FOO";

for (my $i = 0; $i <= 5; $i++) {
	print "$i ... ";
	sleep 2;
}

When I run the testing.cgi script (in the browser), I correctly see this (all be it after 10 seconds, due to the "sleep" commands);

FOO0 ... 1 ... 2 ... 3 ... 4 ... 5 ... 

However, when I run nph-testing.cgi (again, in the browser), I get:

Content-Type: text/html

FOO0 ... 1 ... 2 ... 3 ... 4 ... 5 ... 

As you can see, its printing the header out - instead of telling the browser that: a) this needs to be a HTML page, and b) that it should be doing this via nph

I'm a bit baffled as to what could suddenly be causing this to occur. At first, I thought my script was outputting some content BEFORE I had printed the correct header - but this test script proves that not the case.

Anyone got any suggestions? I'm drawing a blank here (and the techs for the server are not too helpful, as they don't seem to know much about Perl)

TIA

Andy

Replies are listed 'Best First'.
Re: NPH script stopped working correctly
by andal (Hermit) on May 15, 2015 at 11:14 UTC

    Well, this question is not so much about Perl, but rather about HTTP. It could be that something was changed in your HTTP server, so that it stopped interpreting your script as it was doing before. So, you may want to contact support for your HTTP server.

    On a side-note, normally nph scripts should output something like "HTTP/1.0 200 OK\n" as first line. Without this line, my server produces output as object for download instead of display. But I don't know about your server.

      Thanks for the reply. That got me onto the right tracks :)

      For some reason (whatever changed), meant that I should now be using:

      	print $IN->header( { -nph => 1 } );

      Adding this into the script (at the top), and it works just as it should now. Thank God! It was driving me nuts!

      Thanks everyone for your time!

      Andy

      Hi,

      Thanks for the reply. Yeah, we have no changed anything in the script - it just suddenly stopped working. The support tech said:

      I do not see any recent changes on the server as per your ticket history.
      
      Let me escalate this ticket to one of our senior technician to review your requirement and suggest any possibilities.

      ..so all a bit weird!

      So, if your script has not changed, but is behaving differently then something else has changed. My money is on the web server config.

      Yeah - thats what I was thinking - but its a managed host, and the only one who makes changes to it are myself, and the server support team. From what they are saying, nothing should have changed around that

      i hope for you the server is not an IIS one: i had painfull days with nph pages some years ago..
      
      Anyway if you post your software version some monk maybe can help you.

      haha no way - IIS are horrendious to use! Its a UNIX server, with cPanel and WHMS

      The Perl version comes up as:

      This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

      I can't seem to figure out how to get the httpd version to output! (tried httpd --version and -v, but neither work)

      TIA

      Andy

Re: NPH script stopped working correctly
by hippo (Bishop) on May 15, 2015 at 11:02 UTC
    Our script used to work just fine ...

    So, if your script has not changed, but is behaving differently then something else has changed. My money is on the web server config.

    I'm not an NPH expert (or even close to being one) but I would expect an NPH script to output more headers than just the Content-type. There's no status code for starters - how should the server/client cope with that?

Re: NPH script stopped working correctly
by Discipulus (Canon) on May 15, 2015 at 10:57 UTC
    i hope for you the server is not an IIS one: i had painfull days with nph pages some years ago..

    Anyway if you post your software version some monk maybe can help you.

    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1126758]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found