我有2台与Rest交互的服务器。 1.服务器发送到2.,最终2.响应到服务器1。我想拦截来自服务器1的流,并对一个数据字段进行更改,然后将其发送到服务器2。创建一个中间人各种各样的。
我试图立即捕获流并将其放入文件中... 却没有成功:
<?php
// Opens the file for writing and puts the point to the end of the file.
$myfile = fopen("crLog.txt", "a") or die("Unable to open file!");
$headers = getallheaders();
foreach($_SERVER as $key=>$val){
$txt = $key . ': ' . $val . "\n";
fwrite($myfile, $txt);
}
fwrite($myfile, "---=========---");
foreach(getallheaders() as $name => $value) {
echo "$name: $value\n";
}
fwrite($myfile, "---=========---");
parse_str(file_get_contents($_PUT),$post_vars);
foreach($post_vars as $name => $value) {
echo "$name: $value\n";
}
fwrite($myfile, "---=========---");
var_dump($_PUT);
var_dump($_FILES);
var_dump($_REQUEST);
fwrite($myfile, "\n============\n============\n\n");
fclose($myfile);
?>
enter code here