首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
SWOOLE的http服务获取post请求有问题
### 问题描述 起了一个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 }
发布于5年前 · 20 次浏览 · 来自
提问
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 }
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2021-03-30
huaqingfeng

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