我正在请求包含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()
发送每个标题,但我想知道是否有更好的方式?
谢谢!