dt246813579 2016-01-03 09:20 采纳率: 0%
浏览 37

PHP post server - posttestserver.com如何工作?

I am trying to build a post server similar to posttestserver.com and have been runnning into lots of trouble.

The following returns nothing -

do {
    $data = file_get_contents('php://input');
} while (empty($data));

header('HTTP/1.0 200 OK');
header('Content-Type: text/html');

var_dump($data);

I have also had a look into the use of sockets but the client should be directed to a URL rather than an ip/port for the clients ease. I suspect that this is what i need to use but am not sure where to start.

For what its worth, the client expects an HTTP 2XX response code from its HTTP POST request, and the client will not attempt submitting the next HTTP POST request while a previous request is still in flight.

Any ideas?

  • 写回答

1条回答 默认 最新

  • duanjiagu0655 2016-01-04 01:56
    关注

    It would seem that you cannot capture and view the POST data in the one browser window.

    For what its worth, here is the code that worked in the end -

    $data = file_get_contents('php://input');
    //do something with the data such as write to file or database
    

    Then you could use the data in another PHP script.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题