如何使用带有cURL的响应头文件名保存文件,基于*重定向*响应头

时间:2014-09-12 17:31:37

标签: curl

How do I save a file using the response header filename with cURL类似,但服务器实际上并不返回文件(& Content-Disposition标头),而是重定向到另一台服务器。这会导致cURL有效地忽略J选项。所以流程是:

curl https://example.com/redirect-me-to-my-file -LOJ
-> Redirect (no Content-Disposition) to https://otherexample.com/here-is-my-file
-> File + Content-Disposition header

这会导致cURL将文件保存为“redirect-me-to-my-file”,而不是Content-Disposition标头中的内容。在例如下载Chrome会导致预期的文件名。

有办法解决这个问题吗?

(L,O和J命令行选项的顺序似乎不会影响结果,当我添加-v时,我可以看到第一个响应中缺少Content-Disposition,以及它的存在重定向的响应)

0 个答案:

没有答案
相关问题