php的curl类记录详细的请求过程debug的方法
$f = fopen('curl_debug', 'wb');
curl_setopt($ch,CURLOPT_VERBOSE,true);//默认是标准错误输出中
curl_setopt($ch,CURLOPT_STDERR ,$f);//有了该指令,请求过程记录会写到该文件中记录的文件内容大致如下 :
* Trying 14.215.177.39...
* TCP_NODELAY set
* Connected to www.baidu.com (14.215.177.39) port 80 (#0)
> GET / HTTP/1.1
Host: www.baidu.com
Accept: */*
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: no-cache
< Connection: keep-alive
< Content-Length: 14615
< Content-Type: text/html
< Date: Tue, 02 Nov 2023 16:34:39 GMT
< Pragma: no-cache
< Server: BWS/1.1
< Vary: Accept-Encoding
<
* Connection #0 to host www.baidu.com left intactcurl本身的bug导致如果CURLINFO_HEADER_OUT设置为true时(即开启输出响应头), CURLOPT_VERBOSE会不生效.所以你需要将CURLINFO_HEADER_OUT配置去掉.
版权属于:Joyber
本文链接:https://blog.qqvbc.com/default/898.html
转载时须注明出处及本声明