Problem with POST reply

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I am using PHP to post a request to a server which returns an XML
document.
We have no problems with the same service if we use a get request.
Here is the result:
 
HTTP/1.1 200 OK
Date: Tue, 13 Sep 2005 02:01:53 GMT
Server: Apache
Set-Cookie: MDIN=2005091280922301026;domain=.blah.com;path=/;expires=Fri
31-Dec-2010 23:59:59 GMT
Set-Cookie: mapsize=small;domain=.blah.com;path=/;expires=Fri
31-Dec-2010 23:59:59 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml
 
2000
<?xml version="1.0" encoding="iso-8859-1"?>
<!--Portal:XML-->
<!-- 
ID: Commented out doctype as customisation is not part of the DTD
<!DOCTYPE SYSTEM "http://www.blah.com/dtd/blah.dtd";>
-->

The issue is the '2000' that appears...it inserts itself every 250 lines
or there abouts and screws up the XML.
Heres the code I am using to post the request:
 
function http_post($server, $port, $url, $vars) {
 $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
 $urlencoded = "";
 while (list($key,$value) = each($vars))
  $urlencoded.= urlencode($key) . "=" . urlencode($value) . "&";
 $urlencoded = substr($urlencoded,0,-1); 
 $content_length = strlen($urlencoded);
 $headers = "POST $url HTTP/1.1
Accept: */*
Accept-Language: en-au
Content-Type: application/x-www-form-urlencoded
User-Agent: $user_agent
Host: $server
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: $content_length";
 
 $fp = fsockopen($server, $port, $errno, $errstr);
 if (!$fp) {
  return false;
 }
 
 fputs($fp, $headers);
 fputs($fp, $urlencoded);
 
 $ret = "";
 while (!feof($fp))
  $ret.= fgets($fp, $content_length);
        
 fclose($fp);
 
 return $ret;
 
}
 
Can anyone see where this '2000' might be comming from?
Thanks
Dean.
 

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux