Mailinglisten-Archive |
> Rufe ich das Script aber über Telnet (Windows 2000 -> cmd.exe ->
telnet
> mein.host.at 80 -> GET /script.php HTTP/1.1 -> Host:mein.host.at -> 2x
> CRLF) auf, bekomme ich bei jedem flush anscheinend eine Art
Return-Code
> inklusive zusätzlicher Linebreaks ausgegeben:
> <telnet-output>
> irgendwas, das lang genug ist um flushen zu können.<br />
>
> ef
> noch irgendwas, das lang genug ist um flushen zu können.<br />
>
> 7a
> und letztendlich noch was, das lang genug ist um flushen zu
können.<br />
>
> 14
> </telnet-output>
über das gleiche problem bin ich gestern auch gestolpert ...
das nennt sich chunked transfer-coding
siehe RFC 2616 3.6 Transfer Codings
die zeichen, die du siehst sind teile vom chunk-header, die die
chunk-size der chunk-data in hex angeben ....
wiederlich ! ;)
/* RFC2616 - 3.6.1 - chunk structure
Chunked-Body = *chunk
last-chunk
trailer
CRLF
chunk = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*("0") [ chunk-extension ] CRLF
chunk-extension = *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size(OCTET)
trailer = *(entity-header CRLF)
*/
$chunks = '';
while (true)
{
// fetching first CRLF-position which delimits the chunk-header
if (!($crlf_pos = strpos($data , $crlf)))
break;
// get chunk-header
$chunk_header = substr($data , 0 , $crlf_pos);
// fetching chunk-size from chunk-header
if (!preg_match('°([0-9a-f]+)°i' , $chunk_header , $matches))
break;
// chunk-size is hex ...
$chunk_size = hexdec($matches[1]);
// if chunk-size is zero, we reached the last (empty) chunk
if ($chunk_size == 0)
break;
// new data begins after the chunk-header which ends with a CRLF !
$data = substr($data , $crlf_pos + 2);
// sanity check
if (strlen($data) == 0)
break;
// adding chunk-data with specified chunk-size to chunks
$chunks .= substr($data , 0 , $chunk_size);
// new data begins after the chunk-data which ends with a CRLF !
$data = substr($data , $chunk_size + 2);
}
$data = $chunks;
php::bar PHP Wiki - Listenarchive