简体   繁体   中英

gzinflate(): data error between a python-xmlrpc server and php-xmlrpc client

as mentioned in the title, i have a python-xmlrpc server that a php-xmlrpc client that uses zend-framework (yes the older one and no i can't change that, the machine the client runs on is a server itself and heavily version-controlled) communicates with. Until now everything worked quite well but when trying to send a logfile as a string to the client that exceeds 1233 characters (most logs are far larger than that) i get a gzinflate(): data error. following is the code i use on the server to return the text:

def showlog(loghash):
    aserverlog = f'/home/testing/api/logs/serverlog{str(datetime.now().strftime("%d_%m_%Y_%HH_%MM_%SS"))}' + "_" + "anderer_log.txt"
    with redirect_stdout(open(aserverlog, 'a')):
        print("md5: ", loghash)

    tailfile = f'/path/to/{loghash}.txt'
    with redirect_stdout(open(aserverlog, 'a')):
        print("file?: ", tailfile)
    with open(tailfile, 'r') as h:
        logtail = h.read()
    with redirect_stdout(open(aserverlog, 'a')):
        print("wtf: ", logtail)
    return logtail

here is the php code on the client side:

<!doctype html>
<head>
    <title>Log</title>
</head>
<body>
<?php

function al($className) {
    $include_file =  str_replace("_", "/", $className) . ".php";
    if (!empty($include_file)) {require_once($include_file);} }

spl_autoload_register('al');
session_start();

function dump($obj) {
    Zend_Debug::dump($obj);
    }
    
$loghash = rtrim($_POST['hashinp']);
try {

    $client = new Zend_XmlRpc_Client("http://serverip/RPC2");
    $log = $client->call("showlog", $loghash);

    } catch (Zend_XmlRpc_Client_FaultException $e) {
        dump("Exception");
        dump($e->getCode());
        dump($e->getMessage());
        dump($client->getLastRequest()->__toString());
        dump($client->getLastResponse()->__toString());
    } catch (Zend_XmlRpc_Client_HttpException $e) {
        dump("Exception2");
        dump($e->getCode());
        dump($e->getMessage());
        dump($client->getLastRequest()->__toString());
        dump($client->getLastResponse());
}

echo '<textarea readonly id="log_output" name="log_output" rows="40" cols="130">'.$log.'</textarea>';

?>
</body>

The full error is:

Warning: gzinflate(): data error in /usr/share/php/Zend/Http/Response.php on line 648

I therefore assume that the error lies within the compression-module of the client side xmlrpc-zend-framework as gzinflate is a php-function for decompression.

Has perhaps anybody stumbled upon this and has a solution? At this point I'm considering either entirely switching to soap (which could be somewhat work and time intensive) or trying to tinker with zend (which obviously is a whole different world of bad idea).

A solution has been found: What was necessary was to deactivate the Compression.

$client = new Zend_XmlRpc_Client("http://serverip/RPC2");
$http_client = $client->getHttpClient();
$http_client->setHeaders('Accept-Encoding: compress');
$ret = $client->call("showlog", $loghash);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM