一个简单的页面,接收到post的数据后,如何生成一个不包含http头的响应?
如请求:
POST /aaa.php HTTP/1.1
Host: x.x.x.x
Accept: */*
Content-Type: application/json; charset=utf-8
Content-Length: 13{"a":1,"b":2}
响应:
{"a":1,"b":2}
如请求:
POST /aaa.php HTTP/1.1
Host: x.x.x.x
Accept: */*
Content-Type: application/json; charset=utf-8
Content-Length: 13{"a":1,"b":2}
响应:
{"a":1,"b":2}
http 客户端并不会将 http头内容交给用户如果你是自己用 sock 写的客户端,那么请自行识别及过滤掉 http头,识别标志 "\r\n\r\n"
$pos = strpos($response, "\r\n\r\n");
$response = substr($response, $pos+4);
可以自己過濾掉http頭。
所以想看看PHP有没有办法实现这个。