包装数据为空?

发布于 11-23 18:41 字数 1840 浏览 2 评论 0原文

我有一个使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋2024-11-30 18:41:26

我发现 cUrl 包装器不会返回标头,除非您在句柄上使用了 fread()

What I discovered is that the cUrl wrapper won't return the headers until you've used fread() on the handle

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文