2

我正在请求一个带有 cURL 的页面并设置了以下选项:

CURLOPT_HEADER => 1,
CURLOPT_NOBODY => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1,

由于一个标头,该请求返回了两组标Location:头,如下所示:

HTTP/1.1 302 Found
Date: Sun, 03 Mar 2013 13:13:24 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.5
X-Debug-Useragent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
Location: http://whateverdomain.com/file.zip
Vary: Accept-Encoding
Content-Type: text/html

HTTP/1.1 200 Ok
Date: Sun, 03 Mar 2013 13:08:45 GMT
Server: nginx
Content-Type: application/octet-string
Content-Length: 309593
Accept-Ranges: bytes
Content-Disposition: attachment; filename="file.zip"
Last-Modified: Sat, 07 Jul 2012 01:29:22 GMT

我想获取最后一个请求(那个200 Ok)的所有标头并将这些标头“转发”给用户。

我可以先分解标题"\n",然后使用 发送每个标题header(),但我想知道是否有更好的方法?

谢谢!

4

0 回答 0