首页
文档
问答
捐赠
源代码
商业产品
Swoole Tracker
Swoole Plus
Swoole Compiler
Swoole 微课程
商业合作
登录
注册
EN
全部
提问
分享
讨论
建议
公告
开发框架
发表新帖
SWOOLE的http服务获取post请求有问题
huaqingfeng
上月
### 问题描述 起了一个http服务,但是服务获取post请求参数不能正常获取。 ### Swoole版本,PHP版本,以及操作系统版本信息 PHP版本:7.3.0 swoole版本:4.6.4 ### 相关代码 ```php 请将代码粘贴至此处(请勿用截图) ``` $http = new Swoole\Http\Server("127.0.0.1", 9503); $http->on('request', function ($request, $response) { var_dump($request); var_dump($request->post); $json = '{"name":"goller","age":"30"}'; $response->end($json); }); $http->start(); ### 你期待的结果是什么?实际看到的错误信息又是什么? 我期待的是post的参数应该和server以及header的参数格式一致,而目前我看到的post请求参数是所有的请求只作为数组的key打印出来了。如下所示: ["server"]=> array(10) { ["request_method"]=> string(4) "POST" ["request_uri"]=> string(1) "/" ["path_info"]=> string(1) "/" ["request_time"]=> int(1617007060) ["request_time_float"]=> float(1617007060.3298) ["server_protocol"]=> string(8) "HTTP/1.1" ["server_port"]=> int(9503) ["remote_port"]=> int(42334) ["remote_addr"]=> string(9) "127.0.0.1" ["master_time"]=> int(1617007060) } ["cookie"]=> NULL ["get"]=> NULL ["files"]=> NULL ["post"]=> array(1) { ["{"name":"goller","action":"search"}"]=> string(0) "" } ["tmpfiles"]=> NULL }
评论
2021-03-29
huaqingfeng

点赞
0
回复
2021-03-29
鲁飞
https://wiki.swoole.com/#/http_server?id=getcontent
点赞
0
回复