Gzinflate():Python-XMLRPC服务器和PHP-XMLRPC客户端之间的数据错误

发布于 2025-02-09 17:36:33 字数 2300 浏览 4 评论 0原文

如标题中所述,我有一个使用zend-framework的php-xmlrpc客户端的Python-XMLRPC服务器(是的,较旧的,我无法更改它,客户端运行的机器是服务器本身,并且很重版本控制)与。到目前为止,一切效果都很好,但是当试图将日志文件作为字符串发送到超过1233个字符的客户端(大多数日志远远大于此)时,我会得到一个Gzinflate():数据错误。 以下是我在服务器上使用的代码返回文本:

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

这是客户端上的PHP代码:

<!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>

完整错误是:

警告:gzinflate():/usr/share/php/zend/http/response.php in Line 648

中的数据错误

我假设该错误位于客户端xmlrpc-zend-framework的压缩模 - 中,因为gzinframe是Gzinflate是Gzinflate是Gzinflate是用于减压的PHP功能。

也许有人偶然发现了这个问题吗?在这一点上,我正在考虑完全改用肥皂(这可能是有些工作和时间密集的),或者试图用Zend修改(显然是一个完全不同的坏主意世界)。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪落纷纷 2025-02-16 17:36:33

已经发现了一个解决方案:必要的是停用压缩。

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文