开发者社区> 问答> 正文

php扩展yar运行测试用例出错?报错

server端php代码 l_server.php:

<?php

class API {

    /**
     * the doc info will be generated automatically into service info page.
     * @params
     * @return
     */
   public function cwh($parameter = "", $option = "foo") {
          return $this->client_can_not_see($parameter);
    }
    protected function client_can_not_see( $name ) {
      return "你好$name~";
    }
}

$service = new Yar_Server(new API());
//var_dump($service);
$service->handle();
?>
client端php代码:l_client.php
<?php
$client = new Yar_Client("http://127.0.0.1/l_server.php");
$client->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 1);
var_dump($client);
  $result = $client->cwh("xiaohui");
  var_dump($result);exit;
?>
执行:/usr/local/php5/bin/php l_client.php   ,报错如下:

PHP Fatal error:  Uncaught exception 'Yar_Client_Protocol_Exception' with message 'malformed response header '

系统是centos6.4  64位 ,开始以为是安装有误,可安装了几次都这样的,不知谁用过的能否指点下?

展开
收起
爱吃鱼的程序员 2020-06-22 15:13:48 918 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
    很高深的样子,可惜我不懂,顶一下!!!!!!!额。。。检查下你Server端的返回中是否有特殊字符,回车换行之类的都会导致返回一个“畸形”的相应头,导致报 'malformedresponseheader'

    server.php中应该是报错了,很可能是:return  "你好$name~";

    应该是$name~被当成了一个变量

    楼主解决了吗,同样碰到这个问题啊
    2020-06-22 15:14:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载
复杂PHP系统性能瓶颈排查及优化 立即下载