首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
curl两次测试请求swoole_http_server 有两种不同的响应结果
如题,执行两次相同CURL请求 swoole 版本: 1.8.3 php 版本: 5.5.33 --http服务端代码 {{{ class server{ public static function run(){ $serv = new swoole_http_server("0.0.0.0",8801); $serv->on('Request', function($request,$response)use($serv){ $fd=$request->fd; var_dump($request->post); $response->end('test'); $serv->close($fd); }); $serv->start(); } } server::run(); }}} --客户机curl代码,cli运行 {{{ $a_post=array ( 'appkey' => '11425', 'sign' => 'sfasdfeasdfasdfasdfsdafa', ); $ch = curl_init(); // 设置URL和相应的选项 curl_setopt($ch, CURLOPT_URL, "http://172.16.12.10:8801/?app=ip.local"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); //设置为POST方式 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_POSTFIELDS, $a_post);//POST数据 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec($ch); var_dump($result); if($result===false){ echo 'Curl return Error'; } curl_close($ch); var_dump($result); exit; }}} --服务端var_dump($request->post); 显示 {{{ 第一次 array(2) { ["appkey"]=> string(5) "11425" ["sign"]=> string(24) "sfasdfeasdfasdfasdfsdafa" } 第二次 array(2) { ["appkey"]=> string(161) "HTTP/1.1 200 OK Server: swoole-http-server Content-Type: text/html Connection: keep-alive Date: Mon, 04 Apr 2016 12:40:01 GMT Content-Length: 4 test11425" ["sign"]=> string(24) "sfasdfeasdfasdfasdfsdafa" } }}} 以上,困扰了很久,一直没找到解决方法. 万分感谢.
发布于9年前 · 1 次浏览 · 来自
提问
M
Mercury
如题,执行两次相同CURL请求 swoole 版本: 1.8.3 php 版本: 5.5.33 --http服务端代码 {{{ class server{ public static function run(){ $serv = new swoole_http_server("0.0.0.0",8801); $serv->on('Request', function($request,$response)use($serv){ $fd=$request->fd; var_dump($request->post); $response->end('test'); $serv->close($fd); }); $serv->start(); } } server::run(); }}} --客户机curl代码,cli运行 {{{ $a_post=array ( 'appkey' => '11425', 'sign' => 'sfasdfeasdfasdfasdfsdafa', ); $ch = curl_init(); // 设置URL和相应的选项 curl_setopt($ch, CURLOPT_URL, "http://172.16.12.10:8801/?app=ip.local"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); //设置为POST方式 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_POSTFIELDS, $a_post);//POST数据 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec($ch); var_dump($result); if($result===false){ echo 'Curl return Error'; } curl_close($ch); var_dump($result); exit; }}} --服务端var_dump($request->post); 显示 {{{ 第一次 array(2) { ["appkey"]=> string(5) "11425" ["sign"]=> string(24) "sfasdfeasdfasdfasdfsdafa" } 第二次 array(2) { ["appkey"]=> string(161) "HTTP/1.1 200 OK Server: swoole-http-server Content-Type: text/html Connection: keep-alive Date: Mon, 04 Apr 2016 12:40:01 GMT Content-Length: 4 test11425" ["sign"]=> string(24) "sfasdfeasdfasdfasdfsdafa" } }}} 以上,困扰了很久,一直没找到解决方法. 万分感谢.
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2017-08-03
w
whatever
这是一个BUG,在`1.8.4`中做了修复。
赞
0
回复
2017-08-04
H
HI-END燊
谢谢韩老师,等1.8.4发布我再尝试。
赞
0
回复