drkrsx3135168 2012-07-20 15:14
浏览 126

如何获取服务器软件的http标头并设置超时

I'm trying to get the HTTP headers but just the server software example: Apache, Microsoft-iis,Nginx,etc

The function

get_headers($url,1); 

it is too slow i want to set time out if it is possible or an other way ??

thanks

  • 写回答

4条回答 默认 最新

  • dongsong4418 2012-07-20 15:17
    关注

    For the local server, the $_SERVER variable will give you everything exposed by the web server in SERVER_* keys.

    For remote servers you can use libcurl and request just the headers. Then parse the response. It can still be long delay depending on network connectivity and the speed of the other server. To avoid a long delay, e.g. for an offline server, set the curl option for a short timeout (e.g. 5 seconds) using curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5).

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大