\x\Request::raw()
用于获取到HTTP服务-客户端的RAW类型请求数据。
依赖类:\x\Request
方法名:raw()
参数:无
返回值:string
PHP-FPM中使用CURL
发送raw
数据进行测试,示例代码:
function curls($url, $data_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$get_url = "http://IP:9502";
$post_str = '{"user":123,"name":"SW-X"}';
$post_datas = curls($get_url, $post_str);
echo $post_datas;
使用\x\Request::raw()
获得:
string(26) "{"user":123,"name":"SW-X"}"