Strange message in web page

Strange message in web page

am 11.07.2008 11:57:10 von Raymond Wan

Hi all,

I'm receiving a strange message which I think is caused by something I'm
doing with modperl and/or Mason, but I'm not sure what to look for.
Basically, I have a page which refreshes every 3 seconds waiting for
some spawned child process to complete. When it completes, it stops
refreshing (which is expected), but it also displays this at the top of
the page:

null device 1 HTTP/1.1 200 OK Date: Fri, 11 Jul 2008 09:40:57 GMT
Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10
Python/2.4.4 PHP/5.2.0-8+etch11 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2
Perl/v5.8.8 Refresh: 3; url=http://... Keep-Alive: timeout=15, max=84
Connection: Keep-Alive Transfer-Encoding: chunked Content-Type:
text/html; charset=UTF-8 998

I would prefer to not give this information out, but I'm also wondering
if this is indicating some other problem. ("null device" does not sound
good...) I do not know if this is relevant, but my code for forking is
below:

-----
$ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

$SIG{CHLD} = 'IGNORE';

defined (my $kid = fork) or die "Cannot fork: $!\n";
if ($kid) {
chdir $HOMEDIR;
}
else {
setsid () or die "Can't start a new session: $!";

open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";

exec $cmd or die "Cannot execute exec: $!";
}
-----

And to make it refresh, I am doing this Mason code (in another file):

% $r -> headers_out -> set (Refresh => "3; url=$url");

Of course, I don't know if either one of these snippets are the source
of my problem. I also run the same server elsewhere administered by
someone else more knowledgeable than me and I'm not getting the problem
there...so, it could be a server setting. But, I'm not sure what to
look for in the Apache documentation. Does anyone know what the problem
is or where I should be looking?

Thanks in advance!

Ray

Re: Strange message in web page

am 11.07.2008 16:38:59 von John Gateley

On Fri, 11 Jul 2008 18:57:10 +0900
Raymond Wan wrote:

> ... but it also displays this at the top of
> the page:
>
> null device 1 HTTP/1.1 200 OK Date: Fri, 11 Jul 2008 09:40:57 GMT
> ...

You are printing "null device 1" to stdout somewhere in your
code before you print the headers.

Check for debugging statements.

j

--
John Gateley

Re: Strange message in web page

am 11.07.2008 17:10:52 von Raymond Wan

Hi John,

I see...I didn't know it was possible to print anything before
headers... I am not printing that statement, as far as I know, but
maybe a library I am using is. I will look into it...

So, the part after "HTTP/1.1 ...", why is that shown? Is that a web
server setting? What is odd is that it doesn't print at every page.
Just one page...and that one page doesn't always show it...only
sometimes. This is why it is strange to me...but I'll keep looking,
then. So, this is unrelated to modperl...other than debugging code
somewhere?

Thank you!

Ray



John Gateley wrote:
>> ... but it also displays this at the top of
>> the page:
>>
>> null device 1 HTTP/1.1 200 OK Date: Fri, 11 Jul 2008 09:40:57 GMT
>> ...
>>
>
> You are printing "null device 1" to stdout somewhere in your
> code before you print the headers.
>
> Check for debugging statements.
>

Re: Strange message in web page

am 11.07.2008 17:46:15 von Ronald J Kimball

On Sat, Jul 12, 2008 at 12:10:52AM +0900, Raymond Wan wrote:
>
> Hi John,
>
> I see...I didn't know it was possible to print anything before
> headers... I am not printing that statement, as far as I know, but
> maybe a library I am using is. I will look into it...
>
> So, the part after "HTTP/1.1 ...", why is that shown? Is that a web
> server setting? What is odd is that it doesn't print at every page.
> Just one page...and that one page doesn't always show it...only
> sometimes. This is why it is strange to me...but I'll keep looking,
> then. So, this is unrelated to modperl...other than debugging code
> somewhere?

Those are the HTTP response headers. They are showing in the browser
because your script is returning a malformed response, i.e. printing "null
device 1" before the headers. The browser is unable to parse the headers
and treats them as part of the body.

Ronald

Re: Strange message in web page

am 14.07.2008 04:44:54 von Raymond Wan

Hi Ronald,

Ronald J Kimball wrote:
> Those are the HTTP response headers. They are showing in the browser
> because your script is returning a malformed response, i.e. printing "null
> device 1" before the headers. The browser is unable to parse the headers
> and treats them as part of the body.
>

Thanks for this; I still haven't been able to figure out why it is doing
this, but it gives me an idea of what to look for. I didn't know one
could print something before headers; but it sounds like I'm doing
something very wrong... Thanks a lot -- will keep looking...

Ray