RE: [PHP] Spurious newlines when requesting empty php file

2004-12-11 Thread Michael Sims
Carl Michael Skog wrote:
 If I save the response of this command with lynx (lynx -dump
 http://www.formatemp.com/catalog/paynova-reply.php;  somefile),
 I will get three newlines.

Aha! I knew it. :)  See:

http://marc.theaimsgroup.com/?l=php-generalm=110272197009025w=2

Lynx adds the newlines.  Better to use Links instead for this sort of thing.

 If I request this file in a browser and scrutinize the response
 packet in a packet analyser, I see something fishy.

 After the usual header fields part are closed with the usual double
 \r\n sequence, a new header is added, consisting of the character
 0.
 This is the then closed with the double \r\n sequence.

Yes, I've noticed that too, using Ethereal to capture packets.  Try this
with a php file that produces output.  If you capture the packet you'll see
that the output is preceded by a hexidecimal number and followed by 0.
The first hex number is the number of characters in the output.  This does
not happen with plain HTML files, at least not on my test machine.

 Obviously, this is part of the data part of the package, and possibly
 becomes the three newlines I am observing.

No...that's Lynx's fault.

 What does this extra header value come from ?

Aha, just found it:

http://www.apps.ietf.org/rfc/rfc2616.html#sec-3.6.1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Spurious newlines when requesting empty php file

2004-12-11 Thread Carl Michael Skog
Thanks for the answer !

The URL of the file is http://www.formatemp.com/catalog/paynova-reply.php
and the file is definitely empty.
It was created by the touch(UNIX command):
-rw-r--r--   42 foo   foo  0 Dec 10 18:49 paynova-reply.php

The server is configured as follows:
Apache/1.3.33 (Unix) mod_perl/1.29 mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 mod_ssl/2.8.21 OpenSSL/0.9.6b
It is a server configured by my ISP, eXaion.com.

If I save the response of this command with lynx (lynx -dump
http://www.formatemp.com/catalog/paynova-reply.php;  somefile),
I will get three newlines.

If I request this file in a browser and scrutinize the response packet in a
packet analyser, I see something fishy.

After the usual header fields part are closed with the usual double \r\n
sequence, a new header is added, consisting of the character 0.
This is the then closed with the double \r\n sequence.
In other words, the extra hex characters 30, 0D, 0A, 0D, 0A are included in
the data part of the package.


Obviously, this is part of the data part of the package, and possibly
becomes the three newlines I am observing.

What does this extra header value come from ?


Regards,
Carl Michael Skog


-Original Message-
From: Richard Lynch ceo-at-l-i-e.com |PHP General user list|
[mailto:...] 
Sent: den 10 december 2004 22:40
To: .
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Spurious newlines when requesting empty php file

Carl Michael Skog wrote:
 Some strange results with spurious newlines inserted in the response 
 when requesting a php file has led me to investigating what happens 
 when a completely empty php-file is requested.

 I would have thought that the response from a empty php file would 
 also be empty, but, to my surprise, they consist of 3 newlines !!!

 The strange thing is that I observed this behaviour on two completely 
 unrelated servers.

 Is this what can be expected or is it a result of misconfiguration ?

I just tried this with an empty PHP file, and got exactly what I expected.

A valid response with no content at all.

Please specify your software versions, and provide URLs and, as silly as
this sounds, an ls -als empty.php so we can see your empty PHP file.

Also check php.ini for auto_prepend_file and auto_append_file settings,
which might be tacking on blanks.

And, if you are using this as an empty file:
--- not quite empty file - ?php ?
--
then PHP is quite right to send out the newline at the end.


- really empty file - ?php
?-

Note that some editors, under some configurations, will *ADD* a newline to a
file on the last line for historical reasons.

Re-configure your editor *now* if yours does that, our include files and
calls to http://php.net/header will drive you crazy, or you'll end up
mis-using output buffering to solve your non-problem.

--
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Spurious newlines when requesting empty php file

2004-12-10 Thread Richard Lynch
Carl Michael Skog wrote:
 Some strange results with spurious newlines inserted in the response when
 requesting a php file has led me to investigating what happens when a
 completely empty php-file is requested.

 I would have thought that the response from a empty php file would also be
 empty, but, to my surprise, they consist of 3 newlines !!!

 The strange thing is that I observed this behaviour on two completely
 unrelated servers.

 Is this what can be expected or is it a result of misconfiguration ?

I just tried this with an empty PHP file, and got exactly what I expected.

A valid response with no content at all.

Please specify your software versions, and provide URLs and, as silly as
this sounds, an ls -als empty.php so we can see your empty PHP file.

Also check php.ini for auto_prepend_file and auto_append_file settings,
which might be tacking on blanks.

And, if you are using this as an empty file:
--- not quite empty file -
?php
?
--
then PHP is quite right to send out the newline at the end.


- really empty file -
?php
?-

Note that some editors, under some configurations, will *ADD* a newline to
a file on the last line for historical reasons.

Re-configure your editor *now* if yours does that, our include files and
calls to http://php.net/header will drive you crazy, or you'll end up
mis-using output buffering to solve your non-problem.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Spurious newlines when requesting empty php file

2004-12-10 Thread Michael Sims
Richard Lynch wrote:
 Carl Michael Skog wrote:
 I would have thought that the response from a empty php file would
 also be empty, but, to my surprise, they consist of 3 newlines !!!

 I just tried this with an empty PHP file, and got exactly what I
 expected.

 A valid response with no content at all.

 Please specify your software versions, and provide URLs and, as silly
 as this sounds, an ls -als empty.php so we can see your empty PHP
 file.

Maybe he's using lynx -dump url to test this.  Lynx adds several newlines 
to the
output.  However, Links does not:

$ touch empty.php
$ lynx -dump http://localhost/empty.php | od -c
000  \n  \n  \n
003
$ links -dump http://localhost/empty.php | od -c
000

Just to add to the guessing... :)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Spurious newlines when requesting empty php file

2004-12-09 Thread Chris
It seems very unlikely to me that PHP is actually sending extra data. If 
it were a bug, unless it was extremely isolated, quite a lot of people 
(including me) would definitely have noticed it.

You didn't give any information, so I'm just guessing, here goes.
It could be...
...the unicode bytes, that get placed at the beginning of a file when 
saved in Unicode format on Windows (maybe other OSes too, not sure).

...something with the way you're viewing the files, which leads you to 
believe they are empty, but in fact are not.

...something to do with the way you're viewing the data that gets sent, 
which leads you to believe it has 3 newlines in it, but in fact is has not.

I'd say examine those 3 options above, then , if it's still a problem, 
post more details here.

Chris
Carl Michael Skog wrote:
Some strange results with spurious newlines inserted in the response when 
requesting a php file has led me to investigating what happens when a 
completely empty php-file is requested.
I would have thought that the response from a empty php file would also be 
empty, but, to my surprise, they consist of 3 newlines !!!
The strange thing is that I observed this behaviour on two completely unrelated 
servers.
Is this what can be expected or is it a result of misconfiguration ?
Kind regards, 
Carl Michael Skog

 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php