Re: [phpxmlrpc] Problems passing a struct of arrays...

2001-08-27 Thread Edd Dumbill

On Sat, 2001-08-25 at 06:32, Jason L . Buberel wrote:
> Here is the patch that will fix xmlrpc.inc to work with large
> payloads. Not sure how large, but certainly larger than the original
> version. Hope you don't mind the verbose comments...
> 
> -jason

Could you upload this patch/file a bug on the SourceForge site, please?
My initial worry with this patch was that it wouldn't be compatible with
PHP3, still a goal for this project.

-- Edd


 PGP signature


Re: [phpxmlrpc] Problems passing a struct of arrays...

2001-08-24 Thread Jason L . Buberel

Here is the patch that will fix xmlrpc.inc to work with large
payloads. Not sure how large, but certainly larger than the original
version. Hope you don't mind the verbose comments...

-jason

*** xmlrpc.inc  Fri Aug 24 21:48:10 2001
--- /home/jason/src/xmlrpc/xmlrpc.inc   Fri Jul  6 11:23:35 2001
*** class xmlrpcmsg {
*** 556,603 
return $r;
}
// gotta get rid of headers here
!   // From the looks of it, the ereg and ereg_replace methods
!   // will not work on any buffers that are > 20kbytes.
!   // so instead we'll use preg_split and preg_match. When we're done,
!   // we need to leave the header-less data in $data, and make sure that
!   // $_xh[$parser]['ha'] is an array containing all the discarded
!   // headers.
!
!   // There is no sense in check $hdrfind, as it's defined as 0 above
!   // and nothing between there and here can modify it.
!
!   // First, I'm going to use preg_split to divide $data into an array
!   // of strings...
!   $headers = array ();
!   $data_array = preg_split("/\n/", $data);
!   foreach ($data_array as $line)
!   {
!   //echo "LINE: $line\n";
!   $line = trim ($line);
!   // if the line starts with '<', it's not a header...
!   if ( preg_match("/^debug)
-   {
-   foreach ($_xh[$parser]['ha'] as $header)
-   {
-   echo "HEADER: $header\n";
-   }
-   }
-   //if ((!$hdrfnd) && ereg("^(.*)\r\n\r\n",$data,$_xh[$parser]['ha'])) {
-   //  $data=ereg_replace("^.*\r\n\r\n", "", $data);
-   //  $hdrfnd=1;
-   //}
 
if (!xml_parse($parser, $data, sizeof($data))) {
// thanks to Peter Kocks <[EMAIL PROTECTED]>
--- 556,565 
return $r;
}
// gotta get rid of headers here
!   if ((!$hdrfnd) && ereg("^(.*)\r\n\r\n",$data,$_xh[$parser]['ha'])) {
! $data=ereg_replace("^.*\r\n\r\n", "", $data);
! $hdrfnd=1;
}
 
if (!xml_parse($parser, $data, sizeof($data))) {
// thanks to Peter Kocks <[EMAIL PROTECTED]>

--
For information about how to subscribe and unsubscribe from this list
visit http://xmlrpc.usefulinc.com/list.html



Re: [phpxmlrpc] Problems passing a struct of arrays...

2001-08-24 Thread Jason L . Buberel

I've dug through the code a bit more, and I can now see where the
problem is:
 
Near line 559 of xmlrpc.inc, there is the following:
 
// gotta get rid of headers here
if ((!$hdrfnd) && ereg("^(.*)\r\n\r\n",$data,$_xh[$parser]['ha']))
{
  $data=ereg_replace("^.*\r\n\r\n", "", $data);
  $hdrfnd=1;
}
 
Which is failing to remove the headers in the case I describe below. I
can print $data before and after this section of the code, and all of
the HTTP headers are still in place. This only appears to fail when
$data is larger than about 20kbytes. I'm rewriting this section in a
way that should be able to handle larger data segments.
 
I'll post a patch as soon as it's ready... 
 
-jason

On Fri, Aug 24, 2001 at 01:16:10AM -0700, Jason L. Buberel wrote:
> I'm using 1.0b9 with PHP 4.0.4 on RedHat 7.1 Apache 1.3.19. 
> 
> I have successfully gotten a few simple rpc calls working (send in a few 
> strings, get a string back, etc.). I am now working on implementing a 
> function that will return a struct of 7 arrays.
> 
> In the rpc-server, I am using the following to create the reply:
> 
> // use the handy encode method to encode each of these arrays...
> $guid_val = xmlrpc_encode($guid);
> $location_val = xmlrpc_encode($location_id);
> $city_val = xmlrpc_encode($city);
> $state_val = xmlrpc_encode($state);
> $hostname_val = xmlrpc_encode($hostname);
> $uri_val = xmlrpc_encode($uri);
> $version_val = xmlrpc_encode($version);
> 
> // then create a struct from the seven arrays...
> $struct = array ( 'guid' => $guid_val,
>   'location_id' => $location_val,
>   'city' => $city_val,
>   'state' => $state_val,
>   'hostname' => $hostname_val,
>   'uri' => $uri_val,
>   'version' => $version_val);
>  
> // return the struct...
> return new xmlrpcresp ( new xmlrpcval ($struct, 'struct'));
> 
> Each time the method is called, I get a fault code = '2' with a fault string 
> of "Invalid return payload". 
> 
> In addition, the string:
> 
> "XML error at line 1, check URL" 
> 
> ...is printed on standard error.  This string is located on line 567 of 
> xmlrpc.inc. This error message is reached only when the call to 'xml_parse' 
> returns with FALSE, and when the parser says it is still on line number 1. So 
> far, it seems like a problem with the parser (either expat itself or the PHP 
> wrapper code around it).
> 
> Here is the funny part: I then turn on the debug flag and rerun the test 
> client to get a look at the return payload. To the naked eye, the XML reply 
> looks perfect. There are no strange error messages, no extra headers, etc. It 
> starts with the usual:
> 
> 
> 
> 
> 
> 
> guid
> 
> 0
> ...
> 
> and ends with the usual...
> 
> ...
> 
> 
> 
> 
> 
> I even checked the size of the XML payload against the HTTP content size 
> header (Content-length: 25328), and the values are correct
> 
> I have googled on that error message, and it doesn't turn up any exact 
> matches. 
> 
> Does anyone have any good ideas on what is causing the XML parse failure to 
> occur?
> 
> Thanks for any help,
> 
> Jason
> 
> 
> 
> 
> 
> --
> For information about how to subscribe and unsubscribe from this list
> visit http://xmlrpc.usefulinc.com/list.html

-- 

--
For information about how to subscribe and unsubscribe from this list
visit http://xmlrpc.usefulinc.com/list.html