ID:               30649
 Updated by:       [EMAIL PROTECTED]
 Reported By:      l dot zurschmiede at delightsoftware dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Sockets related
 Operating System: Linux 2.6.7
 PHP Version:      5.0.2
 New Comment:

This is not a bug, this is called "Chunked Encoding". See the HTTP RFCs
for more information.


Previous Comments:
------------------------------------------------------------------------

[2004-11-01 13:57:48] l dot zurschmiede at delightsoftware dot com

Description:
------------
When a Socket/Stream function is used to get content,  
bigger then 8000bytes from a HTTP-Server, the received  
content has a false begin (3bb4 or similar) and end  
(0\n\n).  
  
This failure occures only if the Server does not respond  
with a "Content-Length: xx" header AND a clientside  
protocol of HTTP/1.1.  
If the clientside protocol is invalid (like "HTTP 1.1" or  
"HTTP 1.0") or it's an old one like HTTP/1.0, there is no  
failure. It only occures with HTTP/1.1 and NO serverside  
"Content-Length" header.  
  
The example-Script is a Server and a Client-Script. The  
Server-Script sends exactly 8001 bytes as content to the  
Client-Script. Comment out the "Content-Length" in Server,  
or the additional $cont .= "."; to retrieve the valid  
content.  
  
(Tested on PHP-5.0.2 with Apache 2.0.50, glibc-2.3.2) 
(A similarly one seams to be #28955) 

Reproduce code:
---------------
Client test_client.php:
<?php
$cont = '';
$head = '';
$fp = stream_socket_client('tcp://localhost:80', $errno, $error, 30);
fputs($fp, "POST /test_server.php HTTP/1.1\r\nHost: localhost\r\n");
fputs($fp, "Connection: Close\r\nAccept: text/xml\r\n\r\n");
while ( $str = trim(fgets($fp, 2048)) )
  $head .= $str;
while ( !(feof($fp)) )
  $cont .= fgets($fp, 2048);
fclose($fp);
print("Length: ".strlen($cont)."<br/>\r\nbegin (10): ".substr($cont, 0,
10)." <br/>\r\nend (10): ".substr($cont, (strlen($cont) - 10)));
?>

Server test_server.php:
<?php
$cont = '';
for ($i = 0; $i < 80; $i++)
  $cont .=
'....................................................................................................';
$cont .= '.';
header('Content-Type: text/plain; charset=\"utf-8\"');
//header('Content-Length: '.strlen($cont));
print($cont);
?>

Expected result:
----------------
Length: 8001<br/> 
begin (10): .......... <br/> 
end (10): .......... 

Actual result:
--------------
Length: 8014<br/> 
begin (10): 1f41 
.... <br/> 
end (10): ... 
0 
 
******* 
There is no exception visible in a backtrace. 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30649&edit=1

Reply via email to