douzhangli9563
2016-08-19 20:53
浏览 357
已采纳

如何生成与Firefox生成相同响应头的cURL请求

When I browse to a page with Firefox and click a download link, the following headers are shown when I inspect the request in network inspector:

Connection: keep-alive
Content-Disposition: attachment; filename="example_file.mp3"
Content-Length: 35181829
Content-Transfer-Encoding: binary
Content-Type: audio/mpeg
Date: Fri, 19 Aug 2016 18:19:02 GMT
Keep-Alive: timeout=60
Server: nginx
X-Powered-By: PHP/5.4.45

However, when I use cURL to visit the same address, I get this:

Connection: keep-alive
Content-Length: 1918
Content-Type: text/html; charset=UTF-8
Date: Fri, 19 Aug 2016 20:46:23 GMT
Keep-Alive: timeout=60
Server: nginx
X-Powered-By: PHP/5.4.45

How can I form a request with cURL that gives me the same response as Firefox?

图片转代码服务由CSDN问答提供 功能建议

当我浏览到使用Firefox的页面并单击下载链接时,检查请求时会显示以下标题 在网络检查器中:

 
Connection:keep-alive 
Content-Disposition:attachment;  filename =“example_file.mp3”
Content-Length:35181829 
ConContent-Transfer-Encoding:binary 
Content-Type:audio / mpeg 
日期:星期五,2016年8月19日18:19:02 GMT 
Keep-Alive:timeout =  60 
服务器:nginx 
X-Powered-By:PHP / 5.4.45 
  
 
 

但是,当我使用cURL访问同一地址时,我得到了这个:

 
Connection:keep-alive 
Content-Length:1918 
Content-Type:text / html;  charset = UTF-8 
日期:星期五,2016年8月19日20:46:23 GMT 
Keep-Alive:timeout = 60 
Server:nginx 
X-Powered-By:PHP / 5.4.45 
  \  n 
 

如何使用cURL形成一个请求,使我得到与Firefox相同的响应?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题