From:             mlemos at acm dot org
Operating system: *
PHP version:      4.3.7
PHP Bug Type:     Sockets related
Bug description:  HTTP 1.1 requests return debug data in the response

Description:
------------
When making an HTTP 1.1 request using fsockopen, the response returns some
numbers at the beginning and the end of the response data returned by fread
that seem like it is debug data, probably the number of unread bytes.

If the request line specifies HTTP 1.0, the problem does not occur. This
problem prevents making HTTP requests to servers that require protocol
1.1.

Reproduce code:
---------------
<?php
  $host="www.php.net";
  $port=80;
  $socket=fsockopen($host,$port,$error);
  if(!$socket)
  {
    echo "socket opening error\n";
    exit;
  }
  echo "connection opened\n";
  $request="GET / HTTP/1.1\r\nHost: www.php.net\r\n\r\n";
  if(!fputs($socket,$request))
  {
    echo "socket writing error\n";
    exit;
  }
  while(!feof($socket))
  {
    $data=fread($socket,1000);
    if(!$data)
      break;
    var_dump($data);
  }
  fclose($socket);
?>

Expected result:
----------------
The actual page headers and content

Actual result:
--------------
Some numbers appear before and after the page content data.

-- 
Edit bug report at http://bugs.php.net/?id=28955&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28955&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28955&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28955&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28955&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28955&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28955&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28955&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28955&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28955&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28955&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28955&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28955&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28955&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28955&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28955&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28955&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28955&r=float

Reply via email to