且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

响应中的HTTP标头包含CURL请求,但不包含浏览器请求

更新时间:2022-12-04 09:00:04

cURL和您的浏览器行为之间没有区别。

There is no difference between cURL and your browser behaviour.

在curl调用中添加-I标志时,将发送 HEAD请求。在您的浏览器中,这是一个 GET请求。

When you add the -I flag in your curl call, you send a 'HEAD' request. In your browser, it was a 'GET' request.

如果使用-i标志(-i在输出中包含HTTP标头)来卷曲此URL,则将丢失 Access-Control-Allow-原始行:

If you curl this url with the -i flag (-i includes the HTTP-header in the output.), you will lose the "Access-Control-Allow-Origin" line :

curl -i -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" http://b17db03a092ebf708b42-9afd7fe2d9c9c6937aeab44904ac3403.r3.cf5.rackcdn.com/artist/samplesong/13111c20aee51aeb480ecbd988cd8cc9.mp3 > C:/curl_return.log

如果打开文件,您会得到:

And if you open the file you got :

HTTP/1.1 200 OK
Content-Length: 480621
Accept-Ranges: bytes
Last-Modified: Mon, 07 Sep 2015 09:19:19 GMT
ETag: b1d4c80b2d5d42a4bf6c1ae5efb289e6
X-Timestamp: 1441617558.54283
Content-Type: audio/mpeg
X-Trans-Id: tx76217fcbee85481d844ab-0055ed6d83iad3
Cache-Control: public, max-age=56913
Expires: Thu, 10 Sep 2015 10:57:04 GMT
Date: Wed, 09 Sep 2015 19:08:31 GMT
Connection: keep-alive

ID3.................................................................
....................................................................