包装数据为空?
我有一个使用 cURL 检索标头的 php 脚本,如 此 链接中所述。这在本地主机上效果很好,但是当我尝试在另一台主机上运行完全相同的脚本时,它将返回一个类似的数组,除了数组 wrapper_data
,不幸的是,这是我需要的部分(我'我试图判断 url 是否是 mp3 文件)。
本地返回
Array
(
[0] =>
)
Array
(
[wrapper_data] => Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: nginx
[2] => Date: Thu, 14 Jul 2011 02:46:34 GMT
[3] => Content-Type: audio/mpeg
[4] => Connection: close
[5] => Last-Modified: Thu, 22 Oct 2009 16:19:38 GMT
[6] => Expires: Fri, 13 Jul 2012 02:46:34 GMT
[7] => Content-Length: 5103556
[8] => X-hawt: very
[9] => X-Orig-Src: 0_mogord
[10] => X-nc: HIT ord 9
[11] => Accept-Ranges: bytes
[12] => Cache-Control: max-age=31536000
)
[wrapper_type] => http
[stream_type] => tcp_socket/ssl
[mode] => r
[unread_bytes] => 0
[seekable] =>
[uri] => http://takethesongsandrun.files.wordpress.com/2009/10/proud-graduates.mp3
[timed_out] =>
[blocked] => 1
[eof] =>
但主机返回
Array
(
[0] =>
)
Array
(
[wrapper_data] => Array
(
[headers] => Array
(
)
[readbuf] => Resource id #14
)
[wrapper_type] => cURL
[stream_type] => cURL
[mode] => r
[unread_bytes] => 0
[seekable] =>
[uri] => http://thedadada.files.wordpress.com/2011/06/06-pulling-on-a-line.mp3
[timed_out] =>
[blocked] => 1
[eof] =>
我知道 cURL 不是问题,因为它可以在我网站的其他地方工作。是否有什么因素阻止正确检索此信息?
I have a php script to retrieve headers using cURL, as described on this link. This works great on a localhost, but when I try to run the exact same script on another host, it will return a similar array, except for the array wrapper_data
which is unfortunately the section I need (I'm trying to figure out if a url is an mp3 file).
Local returns
Array
(
[0] =>
)
Array
(
[wrapper_data] => Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: nginx
[2] => Date: Thu, 14 Jul 2011 02:46:34 GMT
[3] => Content-Type: audio/mpeg
[4] => Connection: close
[5] => Last-Modified: Thu, 22 Oct 2009 16:19:38 GMT
[6] => Expires: Fri, 13 Jul 2012 02:46:34 GMT
[7] => Content-Length: 5103556
[8] => X-hawt: very
[9] => X-Orig-Src: 0_mogord
[10] => X-nc: HIT ord 9
[11] => Accept-Ranges: bytes
[12] => Cache-Control: max-age=31536000
)
[wrapper_type] => http
[stream_type] => tcp_socket/ssl
[mode] => r
[unread_bytes] => 0
[seekable] =>
[uri] => http://takethesongsandrun.files.wordpress.com/2009/10/proud-graduates.mp3
[timed_out] =>
[blocked] => 1
[eof] =>
but the host returns
Array
(
[0] =>
)
Array
(
[wrapper_data] => Array
(
[headers] => Array
(
)
[readbuf] => Resource id #14
)
[wrapper_type] => cURL
[stream_type] => cURL
[mode] => r
[unread_bytes] => 0
[seekable] =>
[uri] => http://thedadada.files.wordpress.com/2011/06/06-pulling-on-a-line.mp3
[timed_out] =>
[blocked] => 1
[eof] =>
I know cURL is not the problem, as it works in other places on my site. Is there something preventing this information from being retrieved properly?
我发现 cUrl 包装器不会返回标头,除非您在句柄上使用了 fread()
What I discovered is that the cUrl wrapper won't return the headers until you've used fread() on the handle