note 64568 added to function.stream-get-line
| From: | php-general at lists dot php dot net | Date: | Tue, 18 Apr 2006 21:07:55 +0000 |
| Subject: | note 64568 added to function.stream-get-line | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108447@lists.php.net to get a copy of this message | ||
In version 5.0.4 using this funtion and then calling ftell($stream) would give you the position up
to but not including the "ending" string.
When I rev'd to PHP version 5.1.2, calling this function then using ftell($stream) would give
the position up to AND including the "ending" string
for example, parsing HTTP responses.
The response from apache using curl....
------------------------------------------------------------
HTTP/1.1 200 OK
Date: Tue, 18 Apr 2006 20:54:59 GMT
Server: Apache/1.3.33 (Unix) PHP/5.0.4 mod_ssl/2.8.22 OpenSSL/0.9.7e
X-Powered-By: PHP/5.0.4
Transfer-Encoding: chunked
Content-Type: text/html
<html><body>test</body></html>
-------------------------------------------------------------
The code:
<?php
$headers = stream_get_line($in,4096,"\r\n\r\n");
fseek ($in,ftell($in)+4);
while (!feof($in)){
fputs ($out,stream_get_line($in,4096,''));
}
?>
prior to my 5.0.4 this worked perfectly, trimming the \r\n\r\n section of the HTTP response and
seperating the top into the $headers string, and the rest was placed into the file handle $out.
using php 5.1.2, the above code chopps off the first 4 bytes of the HTTP response and puts
l><body>test</body></html>
into $out.
----
Server IP: 64.71.164.2
Probable Submitter: 216.16.201.50
----
X-Spam-Status: No, hits=4.7 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE,HTML_TAG_BALANCE_HTML autolearn=no
version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.stream-get-line.php
Edit -- http://master.php.net/note/edit/64568
Del: integrated -- http://master.php.net/note/delete/64568/integrated
Del: useless -- http://master.php.net/note/delete/64568/useless
Del: bad code -- http://master.php.net/note/delete/64568/bad+code
Del: spam -- http://master.php.net/note/delete/64568/spam
Del: non-english -- http://master.php.net/note/delete/64568/non-english
Del: in docs -- http://master.php.net/note/delete/64568/in+docs
Del: other reasons-- http://master.php.net/note/delete/64568
Reject -- http://master.php.net/note/reject/64568
Search -- http://master.php.net/manage/user-notes.php