简体   繁体   English

显示为HTTP请求制作的PHP的确切标头?

[英]Show the exact header PHP made for HTTP requests?

Is there a way to get the exact Headers sent by function like file_get_contents() or get_headers() ? 有没有一种方法可以获取由file_get_contents()get_headers()类的函数发送的确切标头?

like 喜欢

get_headers('http://google.it');
echo php_get_request_headers();  //> ?

Had this issue once so what i use is a proxy such as fiddler http://www.fiddler2.com/fiddler2/ 曾经有这个问题,所以我使用的是诸如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);

It capture all the request sent by this script because of the stream_context_set_default .. this would work for file_get_contents , fopen etc. 由于stream_context_set_default ..它捕获此脚本发送的所有请求。这适用于file_get_contentsfopen等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM