当我浏览到使用Firefox的页面并单击下载链接时,在网络检查器中检查请求时会显示以下标题:
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
但是,当我使用cURL访问同一地址时,我明白了:
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
如何使用cURL形成一个请求,使我得到与Firefox相同的响应?
答案 0 :(得分:0)
示例:
OR
var obj = {
"claimID" : "value",
"rederenceDate" : "value"
}
.......
data: '{ "argPlaceOrderJSON": ' + JSON.stringify(obj) + ' }'
Accept
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding
gzip, deflate
Accept-Language
nl,en-US;q=0.7,en;q=0.3
Connection
keep-alive
Cookie
_ga=GA1.2.598213448.1471644637; _gat=1
Host
mariannesdelights.be
User-Agent
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
这应该产生完全相同的HTTP响应头。