php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28955 HTTP 1.1 requests return debug data in the response
Submitted: 2004-06-29 07:33 UTC Modified: 2004-06-29 11:50 UTC
From: mlemos at acm dot org Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.3.7 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 - 27 = ?
Subscribe to this entry?

 
 [2004-06-29 07:33 UTC] mlemos at acm dot org
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-29 11:50 UTC] rasmus@php.net
I'd suggest you read the HTTP specification.  Pay particular attention to the section on HTTP Chunking.  Absolutely no bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 02:01:30 2024 UTC