From:             c938264 at student dot dtu dot dk
Operating system: freeBSD 4.3, Apache/1.3.27
PHP version:      4.3.0
PHP Bug Type:     Output Control
Bug description:  Linefeed prepended to start of http-body

I found this problem trying to serve a binary file.
The basic structure of this part of my script is:

header('Content-Type: ..');
header('Content-Length: ..');
<output file contents>

where <output file contents> would be readfile or similar. However I
learned that the first byte of the served file was always a 0x0a
(linefeed). I have used telnet to create  requests and log responses, and
I have found that the response has the following structure:

<header><cr><lf>
..
<header><cr><lf>
<cr><lf>
<lf><body-part>

i.e. and extra <lf> prepended to the body part of the response. I have
tested several different scenarios:

* no headers, echo some text
* set chunked transfer encoding, do a readfile
* set chunked transfer encoding, echo some text
* set chunked transfer encoding, use fwrite on php://stdout

All methods prepend the linefeed. The telnet dump verify that the headers
are set correctly, so this should rule-out the possibility that the
linefeed stems from any text before the <? -tag.

PHP is build with the following configuration line:

'./configure' '--with-apache=../apache_1.3.27' '--enable-safe-mode'
'--with-mhash' '--enable-xslt' '--with-xslt-sablot'
'--enable-sablot-errors-descriptive' '--with-pdflib'
'--with-imap=/usr/local/imap' '--with-mcrypt' '--with-pspell'
'--with-gettext' '--with-mysql=/usr/local' '--with-pgsql' '--with-gd'
'--with-ttf' '--with-t1lib' '--with-png-dir'
'--with-zlib-dir=/usr/local/zlib' '--enable-memory-limit'
'--with-jpeg-dir' '--with-freetype-dir'
'--enable-freetype-4bit-antialias-hack' '--with-tiff-dir' '--enable-exif'
'--enable-calendar'

I think this problem may be related to #18740..

/David Holdt
-- 
Edit bug report at http://bugs.php.net/?id=22772&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22772&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22772&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22772&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22772&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22772&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22772&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22772&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22772&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22772&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22772&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22772&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22772&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22772&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22772&r=gnused

Reply via email to