[英]Show the exact header PHP made for HTTP requests?
有沒有一種方法可以獲取由file_get_contents()
或get_headers()
類的函數發送的確切標頭?
喜歡
get_headers('http://google.it');
echo php_get_request_headers(); //> ?
曾經有這個問題,所以我使用的是諸如fiddler
的代理http://www.fiddler2.com/fiddler2/
$default_opts = array(
'http'=>array(
'method'=>"HEAD",
'proxy'=>"tcp://localhost:8888"
)
);
$default = stream_context_set_default($default_opts);
$headers = get_headers('http://google.com');
var_dump($headers);
由於stream_context_set_default
..它捕獲此腳本發送的所有請求。這適用於file_get_contents
, fopen
等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.