ID:               26451
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mflanagan at MJFlanagan dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Output Control
 Operating System: Windows 2000
 PHP Version:      4.3.3
 New Comment:

Change 

fread ($fp, 14096);

to

while (($line = fgets($fp, 1024))) {
$getResponse .= $line;
}


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

[2003-11-28 13:37:23] mflanagan at MJFlanagan dot com

Description:
------------
I have a server page that should be seinding output to a client php
command-line script (not a browser).  The headers arrive at the client,
but the resot of the output doesn't.  The same scripts work correctly
under RH Linux (7.something) and Apache, same version of PHP.

Reproduce code:
---------------
LH_Svc.php: 
<?php
   $resp = "<response>\r\n";

   $respLen = strlen ($resp);
   header ("Content-Type: text/xml");
   header ("Content-Length: $respLen\n");
   echo ($resp);        // send back to caller
   exit;
?>

Client:
 <?php
   $server = "localhost";
   $url = "/earn/LH_Svc.php";
   $port = 80;

   // open socket
   $fp = fsockopen($server, $port);

   if (!$fp) {
      echo "Could not open socket";
   }
   else {
      $postData = "<test>";
      $dataLen = strlen ($postData);

      $postHeader = "POST $url HTTP/1.0\r\n";
      $postHeader .= "User-Agent: PHP-MJF Client\r\n";
      $postHeader .= "Content-Type: text/xml\r\n";
      $postHeader .= "Content-Length: $dataLen\n";
      $postHeader .= "\r\n";  // required extra blank line

      echo ($postHeader);
      echo ($postData);
      echo ("\n====================\n");

      fwrite ($fp, $postHeader);
      fwrite ($fp, $postData);

      $getResponse = fread ($fp, 14096);
      fclose ($fp);

      echo "Length of response is " . strlen ($getResponse) . "\r\n";
      echo $getResponse;

      echo "=====================\n";
   }
?>


Expected result:
----------------
D:\EarnApps>d:\php\php-4.3.3-win32\cli\php.exe post.cli     
 POST /earn/LH.php HTTP/1.0
User-Agent: PHP-MJF Client
Content-Type: text/xml
Content-Length: 6

<test>
====================
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 04 Nov 2003 18:30:44 GMT
X-Powered-By: PHP/4.3.3
Content-Type: text/xml
Content-Length: 10

<response>
=====================


Actual result:
--------------
D:\EarnApps>d:\php\php-4.3.3-win32\cli\php.exe post.cli     
 POST /earn/LH.php HTTP/1.0
User-Agent: PHP-MJF Client
Content-Type: text/xml
Content-Length: 6

<test>
====================
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 04 Nov 2003 18:30:44 GMT
X-Powered-By: PHP/4.3.3
Content-Type: text/xml
Content-Length: 10


=====================



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


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

Reply via email to